summaryrefslogtreecommitdiffstats
path: root/testcases/config_functest.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-12-09 12:07:40 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2015-12-09 14:07:44 +0100
commitd6c3c6ac77bb78e1f7bad6f4d9ce499791fa1cf9 (patch)
treeacb03e1e87739b0469d65c2514bc7d35ed5b129d /testcases/config_functest.py
parent8bea42bb341239f93f8fac24b472c19e9377aa78 (diff)
Create a common network for functest for all the tests
Some installers provide a private network by default, if that is the case, it will not create another one. This is needed for Rally/Tempest to work. Removed from vPing test case, since it will use that network as well. Change-Id: Iaff8a9e18026fe5aba31e567a4a8d5faf4a0bb6b Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/config_functest.py')
-rwxr-xr-xtestcases/config_functest.py67
1 files changed, 66 insertions, 1 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index e66240eed..11b31c9e8 100755
--- a/testcases/config_functest.py
+++ b/testcases/config_functest.py
@@ -68,6 +68,18 @@ RALLY_COMMIT = functest_yaml.get("general").get("openstack").get("rally_stable_c
IMAGE_FILE_NAME = functest_yaml.get("general").get("openstack").get("image_file_name")
IMAGE_PATH = DATA_DIR + "/" + IMAGE_FILE_NAME
+# NEUTRON Private Network parameters
+NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general"). \
+ get("openstack").get("neutron_private_net_name")
+NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general"). \
+ get("openstack").get("neutron_private_subnet_name")
+NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general"). \
+ get("openstack").get("neutron_private_subnet_cidr")
+NEUTRON_ROUTER_NAME = functest_yaml.get("general"). \
+ get("openstack").get("neutron_router_name")
+
+creds_neutron = functest_utils.get_credentials("neutron")
+neutron_client = neutronclient.Client(**creds_neutron)
def action_start():
"""
@@ -85,8 +97,20 @@ def action_start():
# Clean in case there are left overs
logger.debug("Cleaning possible functest environment leftovers.")
action_clean()
-
logger.info("Starting installation of functest environment")
+
+ private_net = functest_utils.get_private_net(neutron_client)
+ if private_net is None:
+ # If there is no private network in the deployment we create one
+ if not create_private_neutron_net(neutron_client):
+ logger.error("There has been a problem while creating the functest network.")
+ action_clean()
+ exit(-1)
+ else:
+ logger.info("Private network '%s' already existing in the deployment."
+ % private_net['name'])
+
+
logger.info("Installing Rally...")
if not install_rally():
logger.error("There has been a problem while installing Rally.")
@@ -262,6 +286,46 @@ def check_rally():
return False
+def create_private_neutron_net(neutron):
+ neutron.format = 'json'
+ logger.info('Creating neutron network %s...' % NEUTRON_PRIVATE_NET_NAME)
+ network_id = functest_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 = functest_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 = functest_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...')
+
+ result = functest_utils.add_interface_router(neutron, router_id, subnet_id)
+
+ if not result:
+ return False
+
+ logger.debug("Interface added successfully.")
+ network_dic = {'net_id': network_id,
+ 'subnet_id': subnet_id,
+ 'router_id': router_id}
+ return True
+
+
def main():
if not (args.action in actions):
logger.error('argument not valid')
@@ -273,6 +337,7 @@ def main():
#TODO: source the credentials in this script
exit(-1)
+
if args.action == "start":
action_start()