aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2018-03-21 08:13:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-03-21 08:13:02 +0000
commita854a1dde960b630c0c0d854dee9232e4c4e9ac8 (patch)
tree731a85dbebaae7b8e5ece8559e58eec512b3d19d /yardstick/common
parentc4228f65829e86abadb7d93246d0b6de9dab2d51 (diff)
parent16aa0b60244b742c2b6478cea93b1eebce4c335f (diff)
Merge "Replace neutron router creation with shade."
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):