From f469d0ae28ebe40e8ec407dd3119f630d0cfb74b Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Thu, 11 Feb 2016 16:26:20 +0100 Subject: Create vPing instances with dynamic ports created by nova/neutron Also, - check if the used network is already created to not create it again - check if the image already exists to not create it again - check if the sec group already exists to not create it again Change-Id: I243619a1538444d836fdda84a86b834668aaf456 Signed-off-by: jose.lausuch (cherry picked from commit 12c1b110e91b2c062b378561f3fb271fe0626aec) --- testcases/functest_utils.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'testcases/functest_utils.py') diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index 94a4fa8a5..838e72634 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -218,6 +218,26 @@ def get_network_id(neutron_client, network_name): return id +def get_subnet_id(neutron_client, subnet_name): + subnets = neutron_client.list_subnets()['subnets'] + id = '' + for s in subnets: + if s['name'] == subnet_name: + id = s['id'] + break + return id + + +def get_router_id(neutron_client, router_name): + routers = neutron_client.list_routers()['routers'] + id = '' + for r in routers: + if r['name'] == router_name: + id = r['id'] + break + return id + + def get_private_net(neutron_client): # Checks if there is an existing shared private network networks = neutron_client.list_networks()['networks'] @@ -419,6 +439,15 @@ def get_security_groups(neutron_client): print "Error [get_security_groups(neutron_client)]:", e return None +def get_security_group_id(neutron_client, sg_name): + security_groups = get_security_groups(neutron_client) + id = '' + for sg in security_groups: + if sg['name'] == sg_name: + id = sg['id'] + break + return id + def create_security_group(neutron_client, sg_name, sg_description): json_body = {'security_group': {'name': sg_name, -- cgit 1.2.3-korg