aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/lib/create_floating_ip.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/lib/create_floating_ip.py')
-rw-r--r--yardstick/benchmark/scenarios/lib/create_floating_ip.py46
1 files changed, 28 insertions, 18 deletions
diff --git a/yardstick/benchmark/scenarios/lib/create_floating_ip.py b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
index 328566d48..e29f9d1fc 100644
--- a/yardstick/benchmark/scenarios/lib/create_floating_ip.py
+++ b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
@@ -7,14 +7,13 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import print_function
-from __future__ import absolute_import
-
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__)
@@ -28,8 +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.setup_done = False
def setup(self):
@@ -43,18 +52,19 @@ class CreateFloatingIp(base.Scenario):
if not self.setup_done:
self.setup()
- net_id = op_utils.get_network_id(self.neutron_client, self.ext_net_id)
- floating_info = op_utils.create_floating_ip(self.neutron_client,
- extnet_id=net_id)
- if floating_info:
- LOG.info("Creating floating ip successful!")
- else:
+ 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!")
+ raise exceptions.ScenarioCreateFloatingIPError
- try:
- keys = self.scenario_cfg.get('output', '').split()
- except KeyError:
- pass
- else:
- values = [floating_info["fip_id"], floating_info["fip_addr"]]
- return self._push_to_outputs(keys, values)
+ result.update({"floating_ip_create": 1})
+ LOG.info("Creating floating ip successful!")
+ keys = self.scenario_cfg.get("output", '').split()
+ values = [floating_info["fip_id"], floating_info["fip_addr"]]
+ return self._push_to_outputs(keys, values)