Example #1
0
def get_flow(context, db, driver, host, volume, ref):
    """Constructs and returns the manager entrypoint flow."""

    flow_name = ACTION.replace(":", "_") + "_manager"
    volume_flow = linear_flow.Flow(flow_name)

    # This injects the initial starting flow values into the workflow so that
    # the dependency order of the tasks provides/requires can be correctly
    # determined.
    create_what = {
        'context': context,
        'volume_ref': volume,
        'manage_existing_ref': ref,
        'optional_args': {
            'is_quota_committed': False
        }
    }

    volume_flow.add(
        create_mgr.NotifyVolumeActionTask(db, "manage_existing.start"),
        PrepareForQuotaReservationTask(db, driver),
        create_api.QuotaReserveTask(), ManageExistingTask(db, driver),
        create_api.QuotaCommitTask(),
        create_mgr.CreateVolumeOnFinishTask(db, "manage_existing.end"))

    # Now load (but do not run) the flow using the provided initial data.
    return taskflow.engines.load(volume_flow, store=create_what)
Example #2
0
def get_flow(scheduler_rpcapi, db_api, create_what):
    """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. Creates the database entry.
    4. Casts to volume manager and scheduler for further processing.
    """

    flow_name = ACTION.replace(":", "_") + "_api"
    api_flow = linear_flow.Flow(flow_name)

    # This will cast it out to either the scheduler or volume manager via
    # the rpc apis provided.
    api_flow.add(create_api.QuotaReserveTask(), EntryCreateTask(db_api),
                 create_api.QuotaCommitTask(),
                 ManageCastTask(scheduler_rpcapi, db_api))

    # Now load (but do not run) the flow using the provided initial data.
    return taskflow.engines.load(api_flow, store=create_what)