aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtestcases/config_functest.py67
-rw-r--r--testcases/config_functest.yaml10
-rw-r--r--testcases/functest_utils.py11
-rw-r--r--testcases/vPing/CI/libraries/vPing.py16
4 files changed, 92 insertions, 12 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py
index e66240ee..11b31c9e 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()
diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml
index 46033577..fc8b1c1b 100644
--- a/testcases/config_functest.yaml
+++ b/testcases/config_functest.yaml
@@ -38,7 +38,6 @@ general:
image_file_name: cirros-0.3.4-x86_64-disk.img
image_disk_format: qcow2
-
#Public network. Optional
neutron_public_net_name: net04_ext
neutron_public_subnet_name: net04_ext__subnet
@@ -53,13 +52,18 @@ general:
neutron_private_subnet_end: 192.168.120.254
neutron_private_subnet_gateway: 192.168.120.254
neutron_router_name: functest-router
+
vping:
ping_timeout: 200
vm_flavor: m1.small #adapt to your environment
vm_name_1: opnfv-vping-1
vm_name_2: opnfv-vping-2
- ip_1: 192.168.120.30
- ip_2: 192.168.120.40
+ vping_private_net_name: vping-net
+ vping_private_subnet_name: vping-subnet
+ vping_private_subnet_cidr: 192.168.130.0/24
+ vping_router_name: vping-router
+ ip_1: 192.168.130.30
+ ip_2: 192.168.130.40
vIMS:
general:
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index d09ae831..7dce96da 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -250,6 +250,17 @@ def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota):
print "Error:", sys.exc_info()[0]
return False
+
+def get_private_net(neutron_client):
+ # Checks if there is an existing private network
+ networks = neutron_client.list_networks()['networks']
+ if len(networks) == 0:
+ return None
+ for net in networks:
+ if net['router:external'] == False:
+ return net
+ return None
+
# ################ GLANCE #################
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index e9f8ad19..e85948b2 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -89,17 +89,17 @@ FLAVOR = functest_yaml.get("vping").get("vm_flavor")
# NEUTRON Private Network parameters
-NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("general"). \
- get("openstack").get("neutron_private_net_name")
+NEUTRON_PRIVATE_NET_NAME = functest_yaml.get("vping"). \
+ get("vping_private_net_name")
-NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("general"). \
- get("openstack").get("neutron_private_subnet_name")
+NEUTRON_PRIVATE_SUBNET_NAME = functest_yaml.get("vping"). \
+ get("vping_private_subnet_name")
-NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("general"). \
- get("openstack").get("neutron_private_subnet_cidr")
+NEUTRON_PRIVATE_SUBNET_CIDR = functest_yaml.get("vping"). \
+ get("vping_private_subnet_cidr")
-NEUTRON_ROUTER_NAME = functest_yaml.get("general"). \
- get("openstack").get("neutron_router_name")
+NEUTRON_ROUTER_NAME = functest_yaml.get("vping"). \
+ get("vping_router_name")
def pMsg(value):