aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-05-09 11:30:21 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-05-09 11:49:47 +0200
commit20627d3d822e78e8a03af5c39a94e18725e858c7 (patch)
tree58f682edbd8b41b4837bcb02b1553df3efe3b7e6 /utils
parent073ca5525f38d7a7c9c67252d1b996e895ff9917 (diff)
Generic Function to create a private network
This is to be used by all the tests which need a private network to work, for example Tempest, Rally, vPing, ssh.. Added example for vPing and promise scripts. Change-Id: I5d79e7b60b81b0f34230ea3ef2f3076697a1958c Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/openstack_utils.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index 2ae2842d..fc89fd2b 100644
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -445,6 +445,62 @@ def remove_gateway_router(neutron_client, router_id):
return False
+def create_network_full(logger,
+ neutron_client,
+ net_name,
+ subnet_name,
+ router_name,
+ cidr):
+
+ # Check if the network already exists
+ network_id = get_network_id(neutron_client, net_name)
+ subnet_id = get_subnet_id(neutron_client, subnet_name)
+ router_id = get_router_id(neutron_client, router_name)
+
+ if network_id != '' and subnet_id != '' and router_id != '':
+ logger.info("A network with name '%s' already exists..." % net_name)
+ else:
+ neutron_client.format = 'json'
+ logger.info('Creating neutron network %s...' % net_name)
+ network_id = create_neutron_net(neutron_client, net_name)
+
+ if not network_id:
+ return False
+
+ logger.debug("Network '%s' created successfully" % network_id)
+ logger.debug('Creating Subnet....')
+ subnet_id = create_neutron_subnet(neutron_client, subnet_name,
+ cidr, network_id)
+ if not subnet_id:
+ return False
+
+ logger.debug("Subnet '%s' created successfully" % subnet_id)
+ logger.debug('Creating Router...')
+ router_id = create_neutron_router(neutron_client, router_name)
+
+ if not router_id:
+ return False
+
+ logger.debug("Router '%s' created successfully" % router_id)
+ logger.debug('Adding router to subnet...')
+
+ if not add_interface_router(neutron_client, router_id, subnet_id):
+ return False
+
+ logger.debug("Interface added successfully.")
+
+ logger.debug('Adding gateway to router...')
+ if not add_gateway_router(neutron_client, router_id):
+ return False
+
+ logger.debug("Gateway added successfully.")
+
+ network_dic = {'net_id': network_id,
+ 'subnet_id': subnet_id,
+ 'router_id': router_id}
+ return network_dic
+
+
# *********************************************
# SEC GROUPS
# *********************************************