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 ##############################################################################
10 from __future__ import print_function
11 from __future__ import absolute_import
15 from yardstick.benchmark.scenarios import base
16 import yardstick.common.openstack_utils as op_utils
18 LOG = logging.getLogger(__name__)
21 class DeleteRouterInterface(base.Scenario):
22 """Unset an OpenStack router interface"""
24 __scenario_type__ = "DeleteRouterInterface"
26 def __init__(self, scenario_cfg, context_cfg):
27 self.scenario_cfg = scenario_cfg
28 self.context_cfg = context_cfg
29 self.options = self.scenario_cfg['options']
31 self.subnet_id = self.options.get("subnet_id", None)
32 self.router_id = self.options.get("router_id", None)
34 self.neutron_client = op_utils.get_neutron_client()
36 self.setup_done = False
41 self.setup_done = True
43 def run(self, result):
44 """execute the test"""
46 if not self.setup_done:
49 status = op_utils.remove_interface_router(self.neutron_client,
50 router_id=self.router_id,
51 subnet_id=self.subnet_id)
53 result.update({"delete_router_interface": 1})
54 LOG.info("Delete router interface successful!")
56 result.update({"delete_router_interface": 0})
57 LOG.error("Delete router interface failed!")