cinder.volume.flows.api.create_volume module

class EntryCreateTask

Bases: CinderTask

Creates an entry for the given volume creation in the database.

Reversion strategy: remove the volume_id created from the database.

default_provides = {'volume', 'volume_id', 'volume_properties'}
execute(context: RequestContext, optional_args: dict, **kwargs) dict[str, Any]

Creates a database entry for the given inputs and returns details.

Accesses the database and creates a new entry for the to be created volume using the given volume properties which are extracted from the input kwargs (and associated requirements this task needs). These requirements should be previously satisfied and validated by a pre-cursor task.

revert(context: RequestContext, result: dict | Failure, optional_args: dict, **kwargs) None

Revert this atom.

This method should undo any side-effects caused by previous execution of the atom using the result of the execute() method and information on the failure which triggered reversion of the flow the atom is contained in (if applicable).

Parameters:
  • args – positional arguments that the atom required to execute.

  • kwargs – any keyword arguments that the atom required to execute; the special key 'result' will contain the execute() result (if any) and the **kwargs key 'flow_failures' will contain any failure information.

class ExtractVolumeRequestTask(image_service: GlanceImageService, availability_zones, **kwargs)

Bases: CinderTask

Processes an api request values into a validated set of values.

This tasks responsibility is to take in a set of inputs that will form a potential volume request and validates those values against a set of conditions and/or translates those values into a valid set and then returns the validated/translated values for use by other tasks.

Reversion strategy: N/A

default_provides = {'availability_zones', 'backup_id', 'cgsnapshot_id', 'consistencygroup_id', 'encryption_key_id', 'group_id', 'multiattach', 'qos_specs', 'refresh_az', 'size', 'snapshot_id', 'source_volid', 'volume_type', 'volume_type_id'}
execute(context: RequestContext, size: int, snapshot: dict | None, image_id: str | None, source_volume: dict | None, availability_zone: str | None, volume_type, metadata, key_manager, consistencygroup, cgsnapshot, group, group_snapshot, backup: dict | None) dict[str, Any]

Activate a given atom which will perform some operation and return.

This method can be used to perform an action on a given set of input requirements (passed in via *args and **kwargs) to accomplish some type of operation. This operation may provide some named outputs/results as a result of it executing for later reverting (or for other atoms to depend on).

NOTE(harlowja): the result (if any) that is returned should be persistable so that it can be passed back into this atom if reverting is triggered (especially in the case where reverting happens in a different python process or on a remote machine) and so that the result can be transmitted to other atoms (which may be local or remote).

Parameters:
  • args – positional arguments that atom requires to execute.

  • kwargs – any keyword arguments that atom requires to execute.

class QuotaCommitTask

Bases: CinderTask

Commits the reservation.

Reversion strategy: N/A (the rollback will be handled by the task that did the initial reservation (see: QuotaReserveTask).

Warning Warning: if the process that is running this reserve and commit process fails (or is killed before the quota is rolled back or committed it does appear like the quota will never be rolled back). This makes software upgrades hard (inflight operations will need to be stopped or allowed to complete before the upgrade can occur). In the future when taskflow has persistence built-in this should be easier to correct via an automated or manual process.

execute(context: RequestContext, reservations, volume_properties, optional_args: dict) dict

Activate a given atom which will perform some operation and return.

This method can be used to perform an action on a given set of input requirements (passed in via *args and **kwargs) to accomplish some type of operation. This operation may provide some named outputs/results as a result of it executing for later reverting (or for other atoms to depend on).

NOTE(harlowja): the result (if any) that is returned should be persistable so that it can be passed back into this atom if reverting is triggered (especially in the case where reverting happens in a different python process or on a remote machine) and so that the result can be transmitted to other atoms (which may be local or remote).

Parameters:
  • args – positional arguments that atom requires to execute.

  • kwargs – any keyword arguments that atom requires to execute.

revert(context: RequestContext, result: dict | Failure, **kwargs) None

Revert this atom.

This method should undo any side-effects caused by previous execution of the atom using the result of the execute() method and information on the failure which triggered reversion of the flow the atom is contained in (if applicable).

Parameters:
  • args – positional arguments that the atom required to execute.

  • kwargs – any keyword arguments that the atom required to execute; the special key 'result' will contain the execute() result (if any) and the **kwargs key 'flow_failures' will contain any failure information.

class QuotaReserveTask

Bases: CinderTask

Reserves a single volume with the given size & the given volume type.

Reversion strategy: rollback the quota reservation.

Warning Warning: if the process that is running this reserve and commit process fails (or is killed before the quota is rolled back or committed it does appear like the quota will never be rolled back). This makes software upgrades hard (inflight operations will need to be stopped or allowed to complete before the upgrade can occur). In the future when taskflow has persistence built-in this should be easier to correct via an automated or manual process.

default_provides = {'reservations'}
execute(context: RequestContext, size: int, volume_type_id, group_snapshot: Snapshot | None, optional_args: dict) dict | None

Activate a given atom which will perform some operation and return.

This method can be used to perform an action on a given set of input requirements (passed in via *args and **kwargs) to accomplish some type of operation. This operation may provide some named outputs/results as a result of it executing for later reverting (or for other atoms to depend on).

NOTE(harlowja): the result (if any) that is returned should be persistable so that it can be passed back into this atom if reverting is triggered (especially in the case where reverting happens in a different python process or on a remote machine) and so that the result can be transmitted to other atoms (which may be local or remote).

Parameters:
  • args – positional arguments that atom requires to execute.

  • kwargs – any keyword arguments that atom requires to execute.

revert(context: RequestContext, result: dict | Failure, optional_args: dict, **kwargs) None

Revert this atom.

This method should undo any side-effects caused by previous execution of the atom using the result of the execute() method and information on the failure which triggered reversion of the flow the atom is contained in (if applicable).

Parameters:
  • args – positional arguments that the atom required to execute.

  • kwargs – any keyword arguments that the atom required to execute; the special key 'result' will contain the execute() result (if any) and the **kwargs key 'flow_failures' will contain any failure information.

class VolumeCastTask(scheduler_rpcapi, volume_rpcapi, db)

Bases: CinderTask

Performs a volume create cast to the scheduler or to the volume manager.

This will signal a transition of the api workflow to another child and/or related workflow on another component.

Reversion strategy: rollback source volume status and error out newly created volume.

execute(context: RequestContext, **kwargs) None

Activate a given atom which will perform some operation and return.

This method can be used to perform an action on a given set of input requirements (passed in via *args and **kwargs) to accomplish some type of operation. This operation may provide some named outputs/results as a result of it executing for later reverting (or for other atoms to depend on).

NOTE(harlowja): the result (if any) that is returned should be persistable so that it can be passed back into this atom if reverting is triggered (especially in the case where reverting happens in a different python process or on a remote machine) and so that the result can be transmitted to other atoms (which may be local or remote).

Parameters:
  • args – positional arguments that atom requires to execute.

  • kwargs – any keyword arguments that atom requires to execute.

revert(context: RequestContext, result: dict | Failure, flow_failures, volume: Volume, **kwargs) None

Revert this atom.

This method should undo any side-effects caused by previous execution of the atom using the result of the execute() method and information on the failure which triggered reversion of the flow the atom is contained in (if applicable).

Parameters:
  • args – positional arguments that the atom required to execute.

  • kwargs – any keyword arguments that the atom required to execute; the special key 'result' will contain the execute() result (if any) and the **kwargs key 'flow_failures' will contain any failure information.

get_flow(db_api, image_service_api, availability_zones, create_what, scheduler_rpcapi=None, volume_rpcapi=None)

Constructs and returns the api entrypoint flow.

This flow will do the following:

  1. Inject keys & values for dependent tasks.

  2. Extracts and validates the input keys & values.

  3. Reserves the quota (reverts quota on any failures).

  4. Creates the database entry.

  5. Commits the quota.

  6. Casts to volume manager or scheduler for further processing.