aboutsummaryrefslogtreecommitdiffstats
path: root/testcases
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 /testcases
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 'testcases')
-rw-r--r--testcases/features/promise.py23
-rw-r--r--testcases/vPing/CI/libraries/vPing_ssh.py76
-rw-r--r--testcases/vPing/CI/libraries/vPing_userdata.py71
3 files changed, 39 insertions, 131 deletions
diff --git a/testcases/features/promise.py b/testcases/features/promise.py
index f10e054cd..c74c7cfa7 100644
--- a/testcases/features/promise.py
+++ b/testcases/features/promise.py
@@ -60,6 +60,12 @@ GLANCE_IMAGE_FORMAT = functest_yaml.get('general').get('openstack').get(
GLANCE_IMAGE_PATH = functest_yaml.get('general').get('directories').get(
'dir_functest_data') + "/" + GLANCE_IMAGE_FILENAME
+NET_NAME = functest_yaml.get('promise').get('general').get('network_name')
+SUBNET_NAME = functest_yaml.get('promise').get('general').get('subnet_name')
+SUBNET_CIDR = functest_yaml.get('promise').get('general').get('subnet_cidr')
+ROUTER_NAME = functest_yaml.get('promise').get('general').get('router_name')
+
+
""" logging configuration """
logger = ft_logger.Logger("promise").getLogger()
@@ -160,13 +166,16 @@ def main():
% (FLAVOR_NAME, flavor_id))
neutron = ntclient.Client(**nt_creds)
- private_net = openstack_utils.get_private_net(neutron)
- if private_net is None:
- logger.error("There is no private network in the deployment."
- "Aborting...")
+
+ network_dic = openstack_utils.create_network_full(logger,
+ neutron,
+ NET_NAME,
+ SUBNET_NAME,
+ ROUTER_NAME,
+ SUBNET_CIDR)
+ if network_dic is False:
+ logger.error("Failed to create the private network...")
exit(-1)
- logger.debug("Using private network '%s' (%s)." % (private_net['name'],
- private_net['id']))
logger.info("Exporting environment variables...")
os.environ["NODE_ENV"] = "functest"
@@ -175,7 +184,7 @@ def main():
os.environ["OS_PASSWORD"] = USER_PWD
os.environ["OS_TEST_IMAGE"] = image_id
os.environ["OS_TEST_FLAVOR"] = flavor_id
- os.environ["OS_TEST_NETWORK"] = private_net['id']
+ os.environ["OS_TEST_NETWORK"] = network_dic["net_id"]
os.chdir(PROMISE_REPO)
results_file_name = 'promise-results.json'
diff --git a/testcases/vPing/CI/libraries/vPing_ssh.py b/testcases/vPing/CI/libraries/vPing_ssh.py
index bd0b9b291..fa9770ba8 100644
--- a/testcases/vPing/CI/libraries/vPing_ssh.py
+++ b/testcases/vPing/CI/libraries/vPing_ssh.py
@@ -78,13 +78,13 @@ FLAVOR = functest_yaml.get("vping").get("vm_flavor")
# NEUTRON Private Network parameters
-NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get(
+PRIVATE_NET_NAME = functest_yaml.get("vping").get(
"vping_private_net_name")
-NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get(
+PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get(
"vping_private_subnet_name")
-NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get(
+PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get(
"vping_private_subnet_cidr")
-NEUTRON_ROUTER_NAME = functest_yaml.get("vping").get(
+ROUTER_NAME = functest_yaml.get("vping").get(
"vping_router_name")
SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name")
@@ -136,63 +136,6 @@ def waitVmDeleted(nova, vm):
return False
-def create_private_neutron_net(neutron):
-
- # Check if the network already exists
- network_id = openstack_utils.get_network_id(neutron,
- NEUTRON_PRIVATE_NET_NAME)
- subnet_id = openstack_utils.get_subnet_id(neutron,
- NEUTRON_PRIVATE_SUBNET_NAME)
- router_id = openstack_utils.get_router_id(neutron,
- NEUTRON_ROUTER_NAME)
-
- if network_id != '' and subnet_id != '' and router_id != '':
- logger.info("Using existing network '%s'..."
- % NEUTRON_PRIVATE_NET_NAME)
- else:
- neutron.format = 'json'
- logger.info('Creating neutron network %s...'
- % NEUTRON_PRIVATE_NET_NAME)
- network_id = openstack_utils.create_neutron_net(
- neutron, NEUTRON_PRIVATE_NET_NAME)
-
- if not network_id:
- return False
- logger.debug("Network '%s' created successfully" % network_id)
- logger.debug('Creating Subnet....')
- subnet_id = openstack_utils.create_neutron_subnet(
- neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR,
- network_id)
- if not subnet_id:
- return False
- logger.debug("Subnet '%s' created successfully" % subnet_id)
- logger.debug('Creating Router...')
- router_id = openstack_utils.create_neutron_router(
- neutron, NEUTRON_ROUTER_NAME)
-
- if not router_id:
- return False
-
- logger.debug("Router '%s' created successfully" % router_id)
- logger.debug('Adding router to subnet...')
-
- if not openstack_utils.add_interface_router(neutron,
- router_id,
- subnet_id):
- return False
- logger.debug("Interface added successfully.")
-
- logger.debug('Adding gateway to router...')
- if not openstack_utils.add_gateway_router(neutron, 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
-
-
def create_security_group(neutron_client):
sg_id = openstack_utils.get_security_group_id(neutron_client,
SECGROUP_NAME)
@@ -291,7 +234,12 @@ def main():
logger.debug("Image '%s' with ID=%s created successfully."
% (GLANCE_IMAGE_NAME, image_id))
- network_dic = create_private_neutron_net(neutron_client)
+ network_dic = openstack_utils.create_network_full(logger,
+ neutron_client,
+ PRIVATE_NET_NAME,
+ PRIVATE_SUBNET_NAME,
+ ROUTER_NAME,
+ PRIVATE_SUBNET_CIDR)
if not network_dic:
logger.error(
"There has been a problem when creating the neutron network")
@@ -345,7 +293,7 @@ def main():
logger.info("Instance '%s' is ACTIVE." % NAME_VM_1)
# Retrieve IP of first VM
- test_ip = vm1.networks.get(NEUTRON_PRIVATE_NET_NAME)[0]
+ test_ip = vm1.networks.get(PRIVATE_NET_NAME)[0]
logger.debug("Instance '%s' got private ip '%s'." % (NAME_VM_1, test_ip))
logger.info("Adding '%s' to security group '%s'..."
@@ -401,7 +349,7 @@ def main():
nolease = False
got_ip = False
discover_count = 0
- cidr_first_octet = NEUTRON_PRIVATE_SUBNET_CIDR.split('.')[0]
+ cidr_first_octet = PRIVATE_SUBNET_CIDR.split('.')[0]
while timeout > 0:
try:
ssh.connect(floatip, username=username,
diff --git a/testcases/vPing/CI/libraries/vPing_userdata.py b/testcases/vPing/CI/libraries/vPing_userdata.py
index 473c1f823..2b2963144 100644
--- a/testcases/vPing/CI/libraries/vPing_userdata.py
+++ b/testcases/vPing/CI/libraries/vPing_userdata.py
@@ -75,13 +75,13 @@ FLAVOR = functest_yaml.get("vping").get("vm_flavor")
# NEUTRON Private Network parameters
-NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping").get(
+PRIVATE_NET_NAME = functest_yaml.get("vping").get(
"vping_private_net_name")
-NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get(
+PRIVATE_SUBNET_NAME = functest_yaml.get("vping").get(
"vping_private_subnet_name")
-NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get(
+PRIVATE_SUBNET_CIDR = functest_yaml.get("vping").get(
"vping_private_subnet_cidr")
-NEUTRON_ROUTER_NAME = functest_yaml.get("vping").get("vping_router_name")
+ROUTER_NAME = functest_yaml.get("vping").get("vping_router_name")
SECGROUP_NAME = functest_yaml.get("vping").get("vping_sg_name")
SECGROUP_DESCR = functest_yaml.get("vping").get("vping_sg_descr")
@@ -132,60 +132,6 @@ def waitVmDeleted(nova, vm):
return False
-def create_private_neutron_net(neutron):
-
- # Check if the network already exists
- network_id = openstack_utils.get_network_id(neutron,
- NEUTRON_PRIVATE_NET_NAME)
- subnet_id = openstack_utils.get_subnet_id(neutron,
- NEUTRON_PRIVATE_SUBNET_NAME)
- router_id = openstack_utils.get_router_id(neutron,
- NEUTRON_ROUTER_NAME)
-
- if network_id != '' and subnet_id != '' and router_id != '':
- logger.info("Using existing network '%s'.." % NEUTRON_PRIVATE_NET_NAME)
- else:
- neutron.format = 'json'
- logger.info('Creating neutron network %s..' % NEUTRON_PRIVATE_NET_NAME)
- network_id = openstack_utils.create_neutron_net(
- neutron, NEUTRON_PRIVATE_NET_NAME)
-
- if not network_id:
- return False
- logger.debug("Network '%s' created successfully" % network_id)
- logger.debug('Creating Subnet....')
- subnet_id = openstack_utils.create_neutron_subnet(
- neutron, NEUTRON_PRIVATE_SUBNET_NAME, NEUTRON_PRIVATE_SUBNET_CIDR,
- network_id)
- if not subnet_id:
- return False
- logger.debug("Subnet '%s' created successfully" % subnet_id)
- logger.debug('Creating Router...')
- router_id = openstack_utils.create_neutron_router(
- neutron, NEUTRON_ROUTER_NAME)
-
- if not router_id:
- return False
-
- logger.debug("Router '%s' created successfully" % router_id)
- logger.debug('Adding router to subnet...')
-
- if not openstack_utils.add_interface_router(neutron, router_id,
- subnet_id):
- return False
- logger.debug("Interface added successfully.")
-
- logger.debug('Adding gateway to router...')
- if not openstack_utils.add_gateway_router(neutron, 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
-
-
def create_security_group(neutron_client):
sg_id = openstack_utils.get_security_group_id(neutron_client,
SECGROUP_NAME)
@@ -286,7 +232,12 @@ def main():
logger.debug("Image '%s' with ID=%s created successfully."
% (GLANCE_IMAGE_NAME, image_id))
- network_dic = create_private_neutron_net(neutron_client)
+ network_dic = openstack_utils.create_network_full(logger,
+ neutron_client,
+ PRIVATE_NET_NAME,
+ PRIVATE_SUBNET_NAME,
+ ROUTER_NAME,
+ PRIVATE_SUBNET_CIDR)
if not network_dic:
logger.error(
"There has been a problem when creating the neutron network")
@@ -346,7 +297,7 @@ def main():
logger.info("Instance '%s' is ACTIVE." % NAME_VM_1)
# Retrieve IP of first VM
- test_ip = vm1.networks.get(NEUTRON_PRIVATE_NET_NAME)[0]
+ test_ip = vm1.networks.get(PRIVATE_NET_NAME)[0]
logger.debug("Instance '%s' got %s" % (NAME_VM_1, test_ip))
# boot VM 2