def index(self, req): """ Returns the following information for all public, available images: * id -- The opaque image identifier * name -- The name of the image * disk_format -- The disk image format * container_format -- The "container" format of the image * checksum -- MD5 checksum of the image data * size -- Size of image data in bytes :param req: The WSGI/Webob Request object :retval The response body is a mapping of the following form:: {'images': [ {'id': <ID>, 'name': <NAME>, 'disk_format': <DISK_FORMAT>, 'container_format': <DISK_FORMAT>, 'checksum': <CHECKSUM> 'size': <SIZE>}, ... ]} """ self._enforce(req, 'get_images') params = self._get_query_params(req) try: images = registry.get_images_list(req.context, **params) except exception.Invalid as e: raise HTTPBadRequest(explanation="%s" % e) return dict(images=images)
def get_orphaned_cached_images(self): """ WRS specific In case glance-caching is used, returns a list of images that were cached, but the original source image has since been deleted """ admin_context = self._get_context() registry.configure_registry_client() active_images = registry.get_images_list(admin_context) cached_images = self.get_cached_images() for c_image in cached_images: if not (any(image['id'] == c_image['image_id'] for image in active_images)): LOG.info( _LI("Image %s no longer present in the " "primary region. Deleting cached file.") % str(c_image['image_id'])) self.delete_cached_image(c_image['image_id']) else: LOG.debug("Image %s still present in the " "primary region." % str(c_image['image_id']))