glance.async_.flows.api_image_import module

class glance.async_.flows.api_image_import.ImportActionWrapper(image_repo, image_id, task_id)[source]

Bases: object

Wrapper for all the image metadata operations we do during an import.

This is used to consolidate the changes we make to image metadata during an import operation, and can be used with an admin-capable repo to enable non-owner controlled modification of that data if desired.

Use this as a context manager to make multiple changes followed by a save of the image in one operation. An _ImportActions object is yielded from the context manager, which defines the available operations.

Parameters:
  • image_repo – The ImageRepo we should use to fetch/save the image

  • image-id – The ID of the image we should be altering

assert_task_lock()[source]

Assert that we own the task lock on the image.

Raises:

TaskAbortedError if we do not

drop_lock_for_task()[source]

Delete the import lock for our task.

This is an atomic operation and thus does not require a context for the image save. Note that after calling this method, no further actions will be allowed on the image.

Raises:

NotFound if the image was not locked by the expected task.

property image_id
glance.async_.flows.api_image_import.assert_quota(context, task_repo, task_id, stores, action_wrapper, enforce_quota_fn, **enforce_kwargs)[source]
glance.async_.flows.api_image_import.get_flow(**kwargs)[source]

Return task flow

Parameters:
  • task_id – Task ID

  • task_type – Type of the task

  • task_repo – Task repo

  • image_repo – Image repository used

  • image_id – ID of the Image to be processed

  • uri – uri for the image file