- logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH))
- image_id = functest_utils.create_glance_image(glance_client,
- GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH)
- if not image_id:
- logger.error("Failed to create a Glance image...")
- exit(-1)
- # Check if the given image exists
- try:
- nova_client.images.find(name=GLANCE_IMAGE_NAME)
- logger.info("Glance image found '%s'" % GLANCE_IMAGE_NAME)
- except:
- logger.error("ERROR: Glance image '%s' not found." % GLANCE_IMAGE_NAME)
- logger.info("Available images are: ")
- exit(-1)
+ volume_types = functest_utils.list_volume_types(cinder_client, private=False)
+ if not volume_types:
+ volume_type = functest_utils.create_volume_type(cinder_client, \
+ CINDER_VOLUME_TYPE_NAME)
+ if not volume_type:
+ logger.error("Failed to create volume type...")
+ exit(-1)
+ else:
+ logger.debug("Volume type '%s' created succesfully..." \
+ % CINDER_VOLUME_TYPE_NAME)
+ else:
+ logger.debug("Using existing volume type(s)...")
+
+ image_id = functest_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
+
+ if image_id == '':
+ logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, \
+ GLANCE_IMAGE_PATH))
+ image_id = functest_utils.create_glance_image(glance_client,\
+ GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH)
+ if not image_id:
+ logger.error("Failed to create the Glance image...")
+ exit(-1)
+ else:
+ logger.debug("Image '%s' with ID '%s' created succesfully ." \
+ % (GLANCE_IMAGE_NAME, image_id))
+ else:
+ logger.debug("Using existing image '%s' with ID '%s'..." \
+ % (GLANCE_IMAGE_NAME,image_id))