From 221da2200131f617d36f3143e730f9dcfab530d0 Mon Sep 17 00:00:00 2001 From: Shobhi Jain Date: Fri, 23 Feb 2018 14:59:09 +0000 Subject: Replace neutron floating ip creation with shade. Function create_floating_ip now uses shade client instead of neutron client. JIRA: YARDSTICK-890 Change-Id: I3defd691dad998cebf98442b52f0555b176f1af4 Signed-off-by: Shobhi Jain --- .../benchmark/scenarios/lib/create_floating_ip.py | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'yardstick/benchmark/scenarios') diff --git a/yardstick/benchmark/scenarios/lib/create_floating_ip.py b/yardstick/benchmark/scenarios/lib/create_floating_ip.py index 7108722af..e29f9d1fc 100644 --- a/yardstick/benchmark/scenarios/lib/create_floating_ip.py +++ b/yardstick/benchmark/scenarios/lib/create_floating_ip.py @@ -11,7 +11,8 @@ import logging import os from yardstick.benchmark.scenarios import base -import yardstick.common.openstack_utils as op_utils +from yardstick.common import openstack_utils +from yardstick.common import exceptions LOG = logging.getLogger(__name__) @@ -26,9 +27,18 @@ class CreateFloatingIp(base.Scenario): self.scenario_cfg = scenario_cfg self.context_cfg = context_cfg self.ext_net_id = os.getenv("EXTERNAL_NETWORK", "external") + self.options = self.scenario_cfg["options"] + + self.network_name_or_id = self.options.get("network_name_or_id", self.ext_net_id) + self.server = self.options.get("server") + self.fixed_address = self.options.get("fixed_address") + self.nat_destination = self.options.get("nat_destination") + self.port = self.options.get("port") + self.wait = self.options.get("wait", False) + self.timeout = self.options.get("timeout", 60) + + self.shade_client = openstack_utils.get_shade_client() - self.neutron_client = op_utils.get_neutron_client() - self.shade_client = op_utils.get_shade_client() self.setup_done = False def setup(self): @@ -36,21 +46,25 @@ class CreateFloatingIp(base.Scenario): self.setup_done = True - def run(self, *args): + def run(self, result): """execute the test""" if not self.setup_done: self.setup() - net_id = op_utils.get_network_id(self.shade_client, self.ext_net_id) - floating_info = op_utils.create_floating_ip(self.neutron_client, - extnet_id=net_id) + floating_info = openstack_utils.create_floating_ip( + self.shade_client, network_name_or_id=self.network_name_or_id, + server=self.server, fixed_address=self.fixed_address, + nat_destination=self.nat_destination, port=self.port, + wait=self.wait, timeout=self.timeout) if not floating_info: + result.update({"floating_ip_create": 0}) LOG.error("Creating floating ip failed!") - return + raise exceptions.ScenarioCreateFloatingIPError + result.update({"floating_ip_create": 1}) LOG.info("Creating floating ip successful!") - keys = self.scenario_cfg.get('output', '').split() + keys = self.scenario_cfg.get("output", '').split() values = [floating_info["fip_id"], floating_info["fip_addr"]] return self._push_to_outputs(keys, values) -- cgit 1.2.3-korg