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 ##############################################################################
13 from yardstick.benchmark.scenarios import base
14 import yardstick.common.openstack_utils as op_utils
17 LOG = logging.getLogger(__name__)
20 class CreateFloatingIp(base.Scenario):
21 """Create an OpenStack floating ip"""
23 __scenario_type__ = "CreateFloatingIp"
25 def __init__(self, scenario_cfg, context_cfg):
26 self.scenario_cfg = scenario_cfg
27 self.context_cfg = context_cfg
28 self.ext_net_id = os.getenv("EXTERNAL_NETWORK", "external")
30 self.neutron_client = op_utils.get_neutron_client()
31 self.shade_client = op_utils.get_shade_client()
32 self.setup_done = False
37 self.setup_done = True
40 """execute the test"""
42 if not self.setup_done:
45 net_id = op_utils.get_network_id(self.shade_client, self.ext_net_id)
46 floating_info = op_utils.create_floating_ip(self.neutron_client,
50 LOG.error("Creating floating ip failed!")
53 LOG.info("Creating floating ip successful!")
54 keys = self.scenario_cfg.get('output', '').split()
55 values = [floating_info["fip_id"], floating_info["fip_addr"]]
56 return self._push_to_outputs(keys, values)