Esempio n. 1
0
def validate_image(cli, image):
    """Validate image"""

    try:
        image_found = api_utils.get_openstack_resource(cli.glance().images,
                                                       image, 'images')
    except (glance_exception.NotFound, exception.ResourceNotFound):
        raise exception.ImageNotFound(image_id=image)
    except glance_exception.HTTPForbidden:
        raise exception.ImageNotAuthorized(image_id=image)
    if not image_found.get('os_distro'):
        raise exception.OSDistroFieldNotFound(image_id=image)
    return image_found
Esempio n. 2
0
    def _get_image_data(self, context, image_ident):
        """Retrieves os_distro and other metadata from the Glance image.

        :param image_ident: image id or name of baymodel.
        """
        try:
            cli = clients.OpenStackClients(context)
            return api_utils.get_openstack_resource(cli.glance().images,
                                                    image_ident, 'images')
        except glanceclient.exc.NotFound:
            raise exception.ImageNotFound(image_id=image_ident)
        except glanceclient.exc.HTTPForbidden:
            raise exception.ImageNotAuthorized(image_id=image_ident)