diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-02-05 15:18:43 +0000 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-03-12 10:39:49 +0000 |
commit | 5bb06d8977dc1ffa18c47cd1b152f84f4a6cfa34 (patch) | |
tree | 4e190c3c8e54b3b21ab397dfa57d4722aa462615 /yardstick/common/openstack_utils.py | |
parent | 066a45edd22be0fa7dec8986b850d672a86ad0a3 (diff) |
Replace neutron network creation with shade.
Function create_neutron_net now uses shade client instead of neutron
client.
JIRA: YARDSTICK-890
Change-Id: I456078e98550901c1f736640c9f9bd0d5f9c3df6
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/common/openstack_utils.py')
-rw-r--r-- | yardstick/common/openstack_utils.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index e3f67baa5..9da37e64b 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -435,13 +435,29 @@ def get_network_id(shade_client, network_name): return networks[0]['id'] -def create_neutron_net(neutron_client, json_body): # pragma: no cover +def create_neutron_net(shade_client, network_name, shared=False, + admin_state_up=True, external=False, provider=None, + project_id=None): + """Create a neutron network. + + :param network_name:(string) name of the network being created. + :param shared:(bool) whether the network is shared. + :param admin_state_up:(bool) set the network administrative state. + :param external:(bool) whether this network is externally accessible. + :param provider:(dict) a dict of network provider options. + :param project_id:(string) specify the project ID this network + will be created on (admin-only). + :returns:(string) the network id. + """ try: - network = neutron_client.create_network(body=json_body) - return network['network']['id'] - except Exception: # pylint: disable=broad-except - log.error("Error [create_neutron_net(neutron_client)]") - raise Exception("operation error") + networks = shade_client.create_network( + name=network_name, shared=shared, admin_state_up=admin_state_up, + external=external, provider=provider, project_id=project_id) + return networks['id'] + except exc.OpenStackCloudException as o_exc: + log.error("Error [create_neutron_net(shade_client)]." + "Exception message, '%s'", o_exc.orig_message) + return None def delete_neutron_net(shade_client, network_id): |