summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-08-25 11:20:17 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-08-26 16:21:30 +0800
commit007868e4810aaf9a2664b030281fe7c818fc3494 (patch)
tree2e060b693956ab112ce1dff28e489377c1057387
parent874eac1d00c9624d084b3c7b01075a7645c5b840 (diff)
refactor create shared network process to eliminate reduplicate
Some places shared network is created through create_network_full first, then update it to shared, abstract a uniformed method to eliminate reduplicate JIRA: FUNCTEST-437 Change-Id: I13c20ab061323188c5eb3b8c861674df38083c62 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
-rwxr-xr-xtestcases/OpenStack/rally/run_rally-cert.py20
-rwxr-xr-xtestcases/OpenStack/tempest/run_tempest.py23
-rwxr-xr-xutils/openstack_utils.py22
3 files changed, 33 insertions, 32 deletions
diff --git a/testcases/OpenStack/rally/run_rally-cert.py b/testcases/OpenStack/rally/run_rally-cert.py
index 279bcde0e..f3eb79d26 100755
--- a/testcases/OpenStack/rally/run_rally-cert.py
+++ b/testcases/OpenStack/rally/run_rally-cert.py
@@ -408,22 +408,12 @@ def main():
exit(-1)
logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME)
- network_dict = os_utils.create_network_full(neutron_client,
- PRIVATE_NET_NAME,
- PRIVATE_SUBNET_NAME,
- ROUTER_NAME,
- PRIVATE_SUBNET_CIDR)
+ network_dict = os_utils.create_shared_network_full(PRIVATE_NET_NAME,
+ PRIVATE_SUBNET_NAME,
+ ROUTER_NAME,
+ PRIVATE_SUBNET_CIDR)
if not network_dict:
- logger.error("Failed to create network...")
- exit(-1)
- else:
- if not os_utils.update_neutron_net(neutron_client,
- network_dict['net_id'],
- shared=True):
- logger.error("Failed to update network...")
- exit(-1)
- else:
- logger.debug("Network '%s' available..." % PRIVATE_NET_NAME)
+ exit(1)
if args.test_name == "all":
for test_name in tests:
diff --git a/testcases/OpenStack/tempest/run_tempest.py b/testcases/OpenStack/tempest/run_tempest.py
index 10b22c9f5..306664feb 100755
--- a/testcases/OpenStack/tempest/run_tempest.py
+++ b/testcases/OpenStack/tempest/run_tempest.py
@@ -125,7 +125,6 @@ def get_info(file_result):
def create_tempest_resources():
keystone_client = os_utils.get_keystone_client()
- neutron_client = os_utils.get_neutron_client()
logger.debug("Creating tenant and user for Tempest suite")
tenant_id = os_utils.create_tenant(keystone_client,
@@ -140,22 +139,12 @@ def create_tempest_resources():
logger.error("Error : Failed to create %s user" % USER_NAME)
logger.debug("Creating private network for Tempest suite")
- network_dic = os_utils.create_network_full(neutron_client,
- PRIVATE_NET_NAME,
- PRIVATE_SUBNET_NAME,
- ROUTER_NAME,
- PRIVATE_SUBNET_CIDR)
- if network_dic:
- if not os_utils.update_neutron_net(neutron_client,
- network_dic['net_id'],
- shared=True):
- logger.error("Failed to update private network...")
- exit(-1)
- else:
- logger.debug("Network '%s' is available..." % PRIVATE_NET_NAME)
- else:
- logger.error("Private network creation failed")
- exit(-1)
+ network_dic = os_utils.create_shared_network_full(PRIVATE_NET_NAME,
+ PRIVATE_SUBNET_NAME,
+ ROUTER_NAME,
+ PRIVATE_SUBNET_CIDR)
+ if not network_dic:
+ exit(1)
logger.debug("Creating image for Tempest suite")
_, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME,
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index a7bc899ab..bc718bb2b 100755
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -671,6 +671,28 @@ def create_network_full(neutron_client,
return network_dic
+def create_shared_network_full(net_name, subnt_name, router_name, subnet_cidr):
+ neutron_client = get_neutron_client()
+
+ network_dic = create_network_full(neutron_client,
+ net_name,
+ subnt_name,
+ router_name,
+ subnet_cidr)
+ if network_dic:
+ if not update_neutron_net(neutron_client,
+ network_dic['net_id'],
+ shared=True):
+ logger.error("Failed to update network %s..." % net_name)
+ return None
+ else:
+ logger.debug("Network '%s' is available..." % net_name)
+ else:
+ logger.error("Network %s creation failed" % net_name)
+ return None
+ return network_dic
+
+
def create_bgpvpn(neutron_client, **kwargs):
# route_distinguishers
# route_targets