def schedule_delayed_delete_from_backend(context, image_id, location): """ Given a location, schedule the deletion of an image location and update location status to db. :param context: The request context :param image_id: The image identifier :param location: The image location entry """ __, db_queue = scrubber.get_scrub_queues() if not CONF.use_user_token: context = None ret = db_queue.add_location(image_id, location, user_context=context) if ret: location['status'] = 'pending_delete' if 'id' in location: # NOTE(zhiyan): New added image location entry will has no 'id' # field since it has not been saved to DB. db_api.get_api().image_location_delete(context, image_id, location['id'], 'pending_delete') else: db_api.get_api().image_location_add(context, image_id, location) return ret
def schedule_delayed_delete_from_backend(context, uri, image_id, **kwargs): """Given a uri, schedule the deletion of an image location.""" (file_queue, _db_queue) = scrubber.get_scrub_queues() # NOTE(zhiyan): Defautly ask glance-api store using file based queue. # In future we can change it using DB based queued instead, # such as using image location's status to saving pending delete flag # when that property be added. if CONF.use_user_token is False: context = None file_queue.add_location(image_id, uri, user_context=context)