1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from yardstick.common import openstack_utils
13 from yardstick.common import exceptions
14 from yardstick.benchmark.scenarios import base
17 LOG = logging.getLogger(__name__)
20 class DeleteRouter(base.Scenario):
21 """Delete an OpenStack router"""
23 __scenario_type__ = "DeleteRouter"
25 def __init__(self, scenario_cfg, context_cfg):
26 self.scenario_cfg = scenario_cfg
27 self.context_cfg = context_cfg
28 self.options = self.scenario_cfg['options']
30 self.router_id = self.options["router_id"]
32 self.shade_client = openstack_utils.get_shade_client()
34 self.setup_done = False
39 self.setup_done = True
41 def run(self, result):
42 """execute the test"""
44 if not self.setup_done:
47 status = openstack_utils.delete_neutron_router(self.shade_client,
50 result.update({"delete_router": 0})
51 LOG.error("Delete router failed!")
52 raise exceptions.ScenarioDeleteRouterError
54 result.update({"delete_router": 1})
55 LOG.info("Delete router successful!")