aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/vPing/CI/libraries
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-05-09 22:44:17 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2015-05-10 01:13:28 +0200
commit8553c686e32c0fa54affb4745e04cce6e36a98ff (patch)
treee7179d7251f14496da92dd74f01a5f729411eefc /testcases/vPing/CI/libraries
parentb4b81658b6e576788a9b7e643004dc3649c5cd32 (diff)
Added functest.yaml to centralize the common parameters for all scripts of functest
adapted scripts to get the parameters from the yaml JIRA: FUNCTEST-1 JIRA: FUNCTEST-3 Change-Id: Id761394c3cd0efec611c9c511adfee041c3f4c58 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/vPing/CI/libraries')
-rw-r--r--testcases/vPing/CI/libraries/vPing.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index ed94df2fa..d140eee18 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -13,26 +13,27 @@
# Note: this is script works only with Ubuntu image, not with Cirros image
#
-import os
+import os, time, subprocess, logging, argparse, yaml
import pprint
-import subprocess
-import time
-import argparse
-import logging
import novaclient.v2.client as novaclient
+import neutronclient.client as neutronclient
#import novaclient.v1_1.client as novaclient
import cinderclient.v1.client as cinderclient
pp = pprint.PrettyPrinter(indent=4)
EXIT_CODE = -1
-#tODO: this parameters should be taken from a conf file
-PING_TIMEOUT = 200
-NAME_VM_1 = "opnfv-vping-1"
-NAME_VM_2 = "opnfv-vping-2"
-GLANCE_IMAGE_NAME = "trusty-server-cloudimg-amd64-disk1.img"
-NEUTRON_NET_NAME = "test"
-FLAVOR = "m1.small"
+with open('../functest.yaml') as f:
+ functest_yaml = yaml.safe_load(f)
+f.close()
+
+PING_TIMEOUT = functest_yaml.get("vping").get("ping_timeout")
+NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1")
+NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2")
+GLANCE_IMAGE_NAME = functest_yaml.get("general").get("openstack").get("image_name")
+NEUTRON_NET_NAME = functest_yaml.get("general").get("openstack").get("neutron_net_name")
+FLAVOR = functest_yaml.get("vping").get("vm_flavor")
+
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
@@ -123,7 +124,7 @@ def main():
print_title("servers list")
pMsg(nova.servers.list())
"""
-
+ # Check if the given image is created
images=nova.images.list()
image_found = False
for image in images:
@@ -136,6 +137,19 @@ def main():
pMsg(nova.images.list())
exit(-1)
+ # Check if the given neutron network is created
+ networks=nova.networks.list()
+ network_found = False
+ for net in networks:
+ if net.human_id == NEUTRON_NET_NAME:
+ logger.info("Network found '%s'" %net.human_id)
+ network_found = True
+ if not network_found:
+ logger.error("ERROR: Neutron network %s not found." % NEUTRON_NET_NAME)
+ logger.info("Available networks are: ")
+ pMsg(nova.networks.list())
+ exit(-1)
+
servers=nova.servers.list()
for server in servers:
if server.name == NAME_VM_1 or server.name == NAME_VM_2: