예제 #1
0
def remove_images(glance_client, default_images):
    logger.debug("Removing Glance images...")
    images = os_utils.get_images(glance_client)
    if images is None:
        return -1
    images = {image.id: image.name for image in images}
    if len(images) == 0:
        logger.debug("No images found.")
        return

    for image in images:
        image_id = image
        image_name = images.get(image_id)
        logger.debug("'%s', ID=%s " % (image_name, image_id))
        if (image_id not in default_images
                and image_name not in default_images.values()):
            logger.debug("Removing image '%s', ID=%s ..." %
                         (image_name, image_id))
            if os_utils.delete_glance_image(glance_client, image_id):
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the"
                             "image %s..." % image_id)
        else:
            logger.debug("   > this is a default image and will "
                         "NOT be deleted.")
예제 #2
0
def get_images(nova_client):
    logger.debug("Getting images...")
    dic_images = {}
    images = os_utils.get_images(nova_client)
    if not (images is None or len(images) == 0):
        for image in images:
            dic_images.update({getattr(image, 'id'): getattr(image, 'name')})
    return {'images': dic_images}
예제 #3
0
def get_images(nova_client):
    logger.debug("Getting images...")
    dic_images = {}
    images = os_utils.get_images(nova_client)
    if not (images is None or len(images) == 0):
        for image in images:
            dic_images.update({getattr(image, 'id'): getattr(image, 'name')})
    return {'images': dic_images}
def get_images(glance_client):
    logger.debug("Getting images...")
    dic_images = {}
    images = os_utils.get_images(glance_client)
    if images is None:
        return -1
    dic_images.update({image.id: image.name for image in images})
    return {'images': dic_images}
예제 #5
0
def remove_images(nova_client, default_images):
    logger.info("Removing Glance images...")
    images = os_utils.get_images(nova_client)
    if images is None or len(images) == 0:
        logger.debug("No images found.")
        return

    for image in images:
        image_name = getattr(image, 'name')
        image_id = getattr(image, 'id')
        logger.debug("'%s', ID=%s " % (image_name, image_id))
        if image_id not in default_images:
            logger.debug("Removing image '%s', ID=%s ..."
                         % (image_name, image_id))
            if os_utils.delete_glance_image(nova_client, image_id):
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the"
                             "image %s..." % image_id)
        else:
            logger.debug("   > this is a default image and will "
                         "NOT be deleted.")
예제 #6
0
def remove_images(nova_client, default_images):
    logger.info("Removing Glance images...")
    images = os_utils.get_images(nova_client)
    if images is None or len(images) == 0:
        logger.debug("No images found.")
        return

    for image in images:
        image_name = getattr(image, 'name')
        image_id = getattr(image, 'id')
        logger.debug("'%s', ID=%s " % (image_name, image_id))
        if image_id not in default_images:
            logger.debug("Removing image '%s', ID=%s ..." %
                         (image_name, image_id))
            if os_utils.delete_glance_image(nova_client, image_id):
                logger.debug("  > Done!")
            else:
                logger.error("There has been a problem removing the"
                             "image %s..." % image_id)
        else:
            logger.debug("   > this is a default image and will "
                         "NOT be deleted.")