summaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-02-21 14:45:21 +0000
committerShobhi Jain <shobhi.jain@intel.com>2018-03-20 15:58:51 +0000
commit16aa0b60244b742c2b6478cea93b1eebce4c335f (patch)
treebd579d996b4632efe61e8ca323d1fc3d6e06af5d /yardstick/common
parent5f61719a12ff20df3679d01578de84110f68302f (diff)
Replace neutron router creation with shade.
Function create_neutron_router now uses shade client instead of neutron client. JIRA: YARDSTICK-890 Change-Id: I819d26f4edb3af5e50f777e8ddbadf4d24820b7f Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/exceptions.py4
-rw-r--r--yardstick/common/openstack_utils.py28
2 files changed, 26 insertions, 6 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 633b36f91..8160c5b0c 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -120,3 +120,7 @@ class MissingPodInfoError(YardstickException):
class UnsupportedPodFormatError(YardstickException):
message = 'Failed to load pod info, unsupported format'
+
+
+class ScenarioCreateRouterError(YardstickException):
+ message = 'Create Neutron Router Scenario failed'
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index 84bfbbbb1..a4fd4e550 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -519,13 +519,29 @@ def create_neutron_subnet(shade_client, network_name_or_id, cidr=None,
return None
-def create_neutron_router(neutron_client, json_body): # pragma: no cover
+def create_neutron_router(shade_client, name=None, admin_state_up=True,
+ ext_gateway_net_id=None, enable_snat=None,
+ ext_fixed_ips=None, project_id=None):
+ """Create a logical router.
+
+ :param name:(string) the router name.
+ :param admin_state_up:(bool) the administrative state of the router.
+ :param ext_gateway_net_id:(string) network ID for the external gateway.
+ :param enable_snat:(bool) enable Source NAT (SNAT) attribute.
+ :param ext_fixed_ips: List of dictionaries of desired IP and/or subnet
+ on the external network.
+ :param project_id:(string) project ID for the router.
+
+ :returns:(string) the router id.
+ """
try:
- router = neutron_client.create_router(json_body)
- return router['router']['id']
- except Exception: # pylint: disable=broad-except
- log.error("Error [create_neutron_router(neutron_client)]")
- raise Exception("operation error")
+ router = shade_client.create_router(
+ name, admin_state_up, ext_gateway_net_id, enable_snat,
+ ext_fixed_ips, project_id)
+ return router['id']
+ except exc.OpenStackCloudException as o_exc:
+ log.error("Error [create_neutron_router(shade_client)]. "
+ "Exception message: %s", o_exc.orig_message)
def delete_neutron_router(shade_client, router_id):