aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/vPing/CI/libraries
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-10-29 00:13:00 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2015-10-29 00:21:18 +0100
commita7d86e93dae2c6e2cac0f6e6dd90613b9dc0acc5 (patch)
treeac2ac4e26100988506325f9a141523e906a7ec68 /testcases/vPing/CI/libraries
parent1a145e36361420713f1497291e79ff3f65d80cc5 (diff)
Move creation of glance image to vPing
Since we only need the glance image in Vping test case, we create it in the vping script, and not in config_functest.py JIRA: FUNCTEST-74 Change-Id: I906ba94344d836bc7835a3dcf478933ff622bd54 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/vPing/CI/libraries')
-rw-r--r--testcases/vPing/CI/libraries/vPing.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index 14671b66..fbe134cb 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -76,8 +76,17 @@ NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1")
NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2")
IP_1 = functest_yaml.get("vping").get("ip_1")
IP_2 = functest_yaml.get("vping").get("ip_2")
-GLANCE_IMAGE_NAME = functest_yaml.get("general"). \
- get("openstack").get("image_name")
+#GLANCE_IMAGE_NAME = functest_yaml.get("general"). \
+# get("openstack").get("image_name")
+GLANCE_IMAGE_NAME="functest-vping"
+GLANCE_IMAGE_FILENAME = functest_yaml.get("general"). \
+ get("openstack").get("image_file_name")
+GLANCE_IMAGE_FORMAT = functest_yaml.get("general"). \
+ get("openstack").get("image_disk_format")
+GLANCE_IMAGE_PATH = functest_yaml.get("general"). \
+ get("directories").get("dir_functest_data") +"/"+GLANCE_IMAGE_FILENAME
+
+
FLAVOR = functest_yaml.get("vping").get("vm_flavor")
# NEUTRON Private Network parameters
@@ -177,11 +186,29 @@ def create_private_neutron_net(neutron):
'router_id': router_id}
return network_dic
+def create_glance_image(path,name,disk_format):
+ """
+ Create a glance image given the absolute path of the image, its name and the disk format
+ """
+ cmd = ("glance image-create --name "+name+" --visibility public "
+ "--disk-format "+disk_format+" --container-format bare --file "+path)
+ functest_utils.execute_command(cmd,logger)
+ return True
+
+def delete_glance_image(name):
+ cmd = ("glance image-delete $(glance image-list | grep %s "
+ "| awk '{print $2}' | head -1)" %name)
+ functest_utils.execute_command(cmd,logger)
+ return True
+
def cleanup(nova, neutron, network_dic):
# delete both VMs
logger.info("Cleaning up...")
+ logger.debug("Deleting image...")
+ delete_glance_image(GLANCE_IMAGE_NAME)
+
vm1 = functest_utils.get_instance_by_name(nova, NAME_VM_1)
if vm1:
logger.debug("Deleting '%s'..." % NAME_VM_1)
@@ -240,8 +267,10 @@ def cleanup(nova, neutron, network_dic):
logger.debug(
"Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME)
+
return True
+
def main():
creds_nova = functest_utils.get_credentials("nova")
@@ -253,6 +282,9 @@ def main():
image = None
flavor = None
+ logger.debug("Creating image '%s' from '%s'..." %(GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH))
+ create_glance_image(GLANCE_IMAGE_PATH,GLANCE_IMAGE_NAME,GLANCE_IMAGE_FORMAT)
+
# Check if the given image exists
try:
image = nova_client.images.find(name=GLANCE_IMAGE_NAME)