Exemplo n.º 1
0
    def _show(self, image_href, method='get'):
        """Returns a dict with image data for the given opaque image id.

        :param image_href: The opaque image identifier.
        :returns: A dict containing image metadata.

        :raises: ImageNotFound
        :raises: ImageUnacceptable if the image status is not active
        """
        LOG.debug("Getting image metadata from glance. Image: %s",
                  image_href)
        image_id = service_utils.parse_image_id(image_href)

        image = self.call(method, image_id)

        if not service_utils.is_image_active(image):
            raise exception.ImageUnacceptable(
                image_id=image_id,
                reason=_("The image is required to be in an active state."))

        if not service_utils.is_image_available(self.context, image):
            raise exception.ImageNotFound(image_id=image_id)

        base_image_meta = service_utils.translate_from_glance(image)
        return base_image_meta
Exemplo n.º 2
0
    def _show(self, image_href, method='get'):
        """Returns a dict with image data for the given opaque image id.

        :param image_href: The opaque image identifier.
        :returns: A dict containing image metadata.

        :raises: ImageNotFound
        :raises: ImageUnacceptable if the image status is not active
        """
        LOG.debug("Getting image metadata from glance. Image: %s",
                  image_href)
        image_id = service_utils.parse_image_id(image_href)

        image = self.call(method, image_id)

        if not service_utils.is_image_active(image):
            raise exception.ImageUnacceptable(
                image_id=image_id,
                reason=_("The image is required to be in an active state."))

        if not service_utils.is_image_available(self.context, image):
            raise exception.ImageNotFound(image_id=image_id)

        base_image_meta = service_utils.translate_from_glance(image)
        return base_image_meta
Exemplo n.º 3
0
    def _detail(self, method='list', **kwargs):
        """Calls out to Glance for a list of detailed image information.

        :returns: A list of dicts containing image metadata.
        """
        LOG.debug("Getting a full list of images metadata from glance.")
        params = service_utils.extract_query_params(kwargs, self.version)

        images = self.call(method, **params)

        _images = []
        for image in images:
            if service_utils.is_image_available(self.context, image):
                _images.append(service_utils.translate_from_glance(image))

        return _images
Exemplo n.º 4
0
    def _detail(self, method='list', **kwargs):
        """Calls out to Glance for a list of detailed image information.

        :returns: A list of dicts containing image metadata.
        """
        LOG.debug(_("Getting a full list of images metadata from glance."))
        params = service_utils.extract_query_params(kwargs, self.version)

        images = self.call(method, **params)

        _images = []
        for image in images:
            if service_utils.is_image_available(self.context, image):
                _images.append(service_utils.translate_from_glance(image))

        return _images
Exemplo n.º 5
0
    def _create(self, image_meta, data=None, method='create'):
        """Store the image data and return the new image object.

        :param image_meta: A dict containing image metadata
        :param data: (Optional) File object to create image from.
        :returns: dict -- New created image metadata
        """
        sent_service_image_meta = service_utils.translate_to_glance(image_meta)

        # TODO(ghe): Allow copy-from or location headers Bug #1199532

        if data:
            sent_service_image_meta['data'] = data

        recv_service_image_meta = self.call(method, **sent_service_image_meta)

        return service_utils.translate_from_glance(recv_service_image_meta)
Exemplo n.º 6
0
    def _create(self, image_meta, data=None, method='create'):
        """Store the image data and return the new image object.

        :param image_meta: A dict containing image metadata
        :param data: (Optional) File object to create image from.
        :returns: dict -- New created image metadata
        """
        sent_service_image_meta = service_utils.translate_to_glance(image_meta)

        #TODO(ghe): Allow copy-from or location headers Bug #1199532

        if data:
            sent_service_image_meta['data'] = data

        recv_service_image_meta = self.call(method, **sent_service_image_meta)

        return service_utils.translate_from_glance(recv_service_image_meta)
Exemplo n.º 7
0
    def _show(self, image_href, method="get"):
        """Returns a dict with image data for the given opaque image id.

        :param image_id: The opaque image identifier.
        :returns: A dict containing image metadata.

        :raises: ImageNotFound
        """
        LOG.debug("Getting image metadata from glance. Image: %s" % image_href)
        (image_id, self.glance_host, self.glance_port, use_ssl) = service_utils.parse_image_ref(image_href)

        image = self.call(method, image_id)

        if not service_utils.is_image_available(self.context, image):
            raise exception.ImageNotFound(image_id=image_id)

        base_image_meta = service_utils.translate_from_glance(image)
        return base_image_meta
Exemplo n.º 8
0
    def _show(self, image_href, method='get'):
        """Returns a dict with image data for the given opaque image id.

        :param image_id: The opaque image identifier.
        :returns: A dict containing image metadata.

        :raises: ImageNotFound
        """
        LOG.debug("Getting image metadata from glance. Image: %s" % image_href)
        (image_id, self.glance_host, self.glance_port,
         use_ssl) = service_utils.parse_image_ref(image_href)

        image = self.call(method, image_id)

        if not service_utils.is_image_available(self.context, image):
            raise exception.ImageNotFound(image_id=image_id)

        base_image_meta = service_utils.translate_from_glance(image)
        return base_image_meta