def _delete(self, image_id, location): try: logger.debug(_("Deleting %(location)s") % locals()) store.delete_from_backend(location) except (store.UnsupportedBackend, exception.NotFound): msg = _("Failed to delete image from store (%(uri)s).") % locals() logger.error(msg) ctx = context.RequestContext(is_admin=True, show_deleted=True) db_api.image_update(ctx, image_id, {'status': 'deleted'})
def _delete(self, id, location): try: logger.debug("Deleting %s" % location) store.delete_from_backend(location) except (store.UnsupportedBackend, exception.NotFound): msg = "Failed to delete image from store (%s). " logger.error(msg % uri) ctx = context.RequestContext(is_admin=True, show_deleted=True) db_api.image_update(ctx, id, {"status": "deleted"})
def _delete(self, id, uri, now): file_path = os.path.join(self.datadir, str(id)) try: LOG.debug(_("Deleting %(uri)s") % {'uri': uri}) store.delete_from_backend(uri) except store.UnsupportedBackend: msg = _("Failed to delete image from store (%(uri)s).") LOG.error(msg % {'uri': uri}) write_queue_file(file_path, uri, now) self.registry.update_image(id, {'status': 'deleted'}) utils.safe_remove(file_path)
def _delete(self, id, uri, now): file_path = os.path.join(self.datadir, str(id)) try: logger.debug(_("Deleting %(uri)s") % {'uri': uri}) store.delete_from_backend(uri) except store.UnsupportedBackend: msg = _("Failed to delete image from store (%(uri)s).") logger.error(msg % {'uri': uri}) write_queue_file(file_path, uri, now) self.registry.update_image(id, {'status': 'deleted'}) utils.safe_remove(file_path)
def safe_delete_from_backend(context, image_id, location): """ Given a location, delete an image from the store and update location status to db. This function try to handle all known exceptions which might be raised by those calls on store and DB modules in its implementation. :param context: The request context :param image_id: The image identifier :param location: The image location entry """ try: ret = store_api.delete_from_backend(context, location['url']) location['status'] = 'deleted' if 'id' in location: db_api.get_api().image_location_delete(context, image_id, location['id'], 'deleted') return ret except exception.NotFound: msg = _LW('Failed to delete image %s in store from URI') % image_id LOG.warn(msg) except exception.StoreDeleteNotSupported as e: LOG.warn(utils.exception_to_str(e)) except store_api.UnsupportedBackend: exc_type = sys.exc_info()[0].__name__ msg = (_LE('Failed to delete image %(image_id)s from store: %(exc)s') % dict(image_id=image_id, exc=exc_type)) LOG.error(msg)
def _delete(self, id, uri, now): file_path = os.path.join(self.datadir, str(id)) try: LOG.debug(_("Deleting %(uri)s") % {'uri': uri}) # Here we create a request context with credentials to support # delayed delete when using multi-tenant backend storage ctx = context.RequestContext(auth_tok=self.registry.auth_tok, user=self.admin_user, tenant=self.admin_tenant) store.delete_from_backend(ctx, uri) except store.UnsupportedBackend: msg = _("Failed to delete image from store (%(uri)s).") LOG.error(msg % {'uri': uri}) write_queue_file(file_path, uri, now) self.registry.update_image(id, {'status': 'deleted'}) utils.safe_remove(file_path)
def _delete(self, id, uri, now): file_path = os.path.join(self.datadir, str(id)) if CONF.metadata_encryption_key is not None: uri = crypt.urlsafe_decrypt(CONF.metadata_encryption_key, uri) try: LOG.debug(_("Deleting %(id)s") % {'id': id}) # Here we create a request context with credentials to support # delayed delete when using multi-tenant backend storage ctx = context.RequestContext(auth_tok=self.registry.auth_tok, user=self.admin_user, tenant=self.admin_tenant) store.delete_from_backend(ctx, uri) except store.UnsupportedBackend: msg = _("Failed to delete image from store (%(id)s).") LOG.error(msg % {'id': id}) except exception.NotFound: msg = _("Image not found in store (%(id)s).") LOG.error(msg % {'id': id}) self.registry.update_image(id, {'status': 'deleted'}) utils.safe_remove(file_path)