Ejemplo n.º 1
0
def get_flow(context, workflow_engine, checkpoint, provider, verify):
    resource_graph = checkpoint.resource_graph
    operation_log = utils.create_operation_log_verify(context, verify)
    parameters = verify.parameters
    flow_name = "Verify_" + checkpoint.id
    verify_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_VERIFY,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters)

    workflow_engine.add_tasks(verify_flow, InitiateVerifyTask(),
                              resources_task_flow, CompleteVerifyTask())

    flow_engine = workflow_engine.get_engine(verify_flow,
                                             store={
                                                 'context': context,
                                                 'checkpoint': checkpoint,
                                                 'verify': verify,
                                                 'new_resources': {},
                                                 'operation_log': operation_log
                                             })
    return flow_engine
Ejemplo n.º 2
0
def get_flow(context, workflow_engine, checkpoint, provider, restore,
             restore_auth):
    resource_graph = checkpoint.resource_graph
    operation_log = utils.create_operation_log_restore(context, restore)
    parameters = restore.parameters
    flow_name = "Restore_" + checkpoint.id
    restore_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_RESTORE,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters)

    workflow_engine.add_tasks(restore_flow, InitiateRestoreTask(),
                              resources_task_flow, CompleteRestoreTask())
    flow_engine = workflow_engine.get_engine(restore_flow,
                                             store={
                                                 'context': context,
                                                 'checkpoint': checkpoint,
                                                 'restore': restore,
                                                 'new_resources': {},
                                                 'operation_log': operation_log
                                             })
    return flow_engine
Ejemplo n.º 3
0
    def _walk_operation(self,
                        protection,
                        operation_type,
                        checkpoint='checkpoint',
                        parameters={},
                        context=None,
                        heat_template=None,
                        **kwargs):
        plugin_map = {
            parent_type: protection,
            child_type: protection,
            grandchild_type: protection,
        }
        flow = resource_flow.build_resource_flow(operation_type, context,
                                                 self.taskflow_engine,
                                                 plugin_map, self.test_graph,
                                                 parameters)

        store = {'checkpoint': checkpoint}
        if heat_template:
            store['heat_template'] = heat_template

        engine = self.taskflow_engine.get_engine(flow,
                                                 engine='parallel',
                                                 store=store)
        self.taskflow_engine.run_engine(engine)
Ejemplo n.º 4
0
def get_flow(context, workflow_engine, operation_type, plan, provider,
             checkpoint):
    protectable_registry = ProtectableRegistry()
    resources = set(Resource(**item) for item in plan.get("resources"))
    resource_graph = protectable_registry.build_graph(context, resources)
    checkpoint.resource_graph = resource_graph
    checkpoint.commit()
    flow_name = "Protect_" + plan.get('id')
    protection_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=operation_type,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=plan.get('parameters'),
    )
    workflow_engine.add_tasks(
        protection_flow,
        InitiateProtectTask(),
        resources_task_flow,
        CompleteProtectTask(),
    )
    flow_engine = workflow_engine.get_engine(protection_flow,
                                             store={'checkpoint': checkpoint})
    return flow_engine
Ejemplo n.º 5
0
def get_flow(context, protectable_registry, workflow_engine, plan, provider,
             checkpoint):
    resources = set(Resource(**item) for item in plan.get("resources"))
    resource_graph = protectable_registry.build_graph(context, resources)
    checkpoint.resource_graph = resource_graph
    checkpoint.commit()
    operation_log = utils.create_operation_log(context, checkpoint)
    flow_name = "Protect_" + plan.get('id')
    protection_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    parameters = plan.get('parameters')
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_PROTECT,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters,
    )
    workflow_engine.add_tasks(
        protection_flow,
        InitiateProtectTask(),
        resources_task_flow,
        CompleteProtectTask(),
    )
    flow_engine = workflow_engine.get_engine(protection_flow,
                                             store={
                                                 'context': context,
                                                 'checkpoint': checkpoint,
                                                 'operation_log': operation_log
                                             })
    return flow_engine
Ejemplo n.º 6
0
    def _walk_operation(self, protection, operation_type,
                        checkpoint='checkpoint', parameters={}, context=None,
                        heat_template=None, **kwargs):
        plugin_map = {
            parent_type: protection,
            child_type: protection,
            grandchild_type: protection,
        }
        flow = resource_flow.build_resource_flow(operation_type,
                                                 context,
                                                 self.taskflow_engine,
                                                 plugin_map,
                                                 self.test_graph,
                                                 parameters)

        store = {
            'checkpoint': checkpoint
        }
        if heat_template:
            store['heat_template'] = heat_template

        engine = self.taskflow_engine.get_engine(flow,
                                                 engine='parallel',
                                                 store=store)
        self.taskflow_engine.run_engine(engine)
Ejemplo n.º 7
0
def get_flow(context, protectable_registry, workflow_engine, plan, provider,
             checkpoint):
    # The 'extra-info' field of resources in plan is optional
    # The extra_info field of the resource is a dict.
    # The dict can not be handled by build_graph. It will throw a
    # error. TypeError: unhashable type: 'dict'
    resources = set()
    for item in plan.get("resources"):
        item["extra_info"] = None
        resources.add(Resource(**item))

    resource_graph = protectable_registry.build_graph(context, resources)
    checkpoint.resource_graph = resource_graph
    checkpoint.commit()
    flow_name = "Protect_" + plan.get('id')
    protection_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_PROTECT,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=plan.get('parameters'),
    )
    workflow_engine.add_tasks(
        protection_flow,
        InitiateProtectTask(),
        resources_task_flow,
        CompleteProtectTask(),
    )
    flow_engine = workflow_engine.get_engine(protection_flow,
                                             store={'checkpoint': checkpoint})
    return flow_engine
Ejemplo n.º 8
0
def get_flow(context, workflow_engine, operation_type, plan, provider,
             checkpoint):
    protectable_registry = ProtectableRegistry()
    resources = set(Resource(**item) for item in plan.get("resources"))
    resource_graph = protectable_registry.build_graph(context,
                                                      resources)
    checkpoint.resource_graph = resource_graph
    checkpoint.commit()
    flow_name = "Protect_" + plan.get('id')
    protection_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=operation_type,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=plan.get('parameters'),
    )
    workflow_engine.add_tasks(
        protection_flow,
        InitiateProtectTask(),
        resources_task_flow,
        CompleteProtectTask(),
    )
    flow_engine = workflow_engine.get_engine(protection_flow, store={
        'checkpoint': checkpoint
    })
    return flow_engine
Ejemplo n.º 9
0
def get_flow(context, workflow_engine, checkpoint, provider):
    LOG.info("Start get checkpoint flow, checkpoint_id: %s", checkpoint.id)
    flow_name = "Delete_Checkpoint_" + checkpoint.id
    delete_flow = workflow_engine.build_flow(flow_name, 'linear')
    resource_graph = checkpoint.resource_graph
    operation_log = utils.create_operation_log(context, checkpoint)
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_DELETE,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=None)
    workflow_engine.add_tasks(
        delete_flow,
        InitiateDeleteTask(),
        resources_task_flow,
        CompleteDeleteTask(),
    )
    flow_engine = workflow_engine.get_engine(delete_flow,
                                             store={
                                                 'context': context,
                                                 'checkpoint': checkpoint,
                                                 'operation_log': operation_log
                                             })
    return flow_engine
Ejemplo n.º 10
0
def get_flow(context, workflow_engine, checkpoint, provider, restore,
             restore_auth):
    target = restore.get('restore_target', None)

    heat_conf = {}
    if target is not None:
        heat_conf["auth_url"] = target
        if restore_auth is not None:
            auth_type = restore_auth.get("type", None)
            if auth_type == "password":
                heat_conf["username"] = restore_auth["username"]
                heat_conf["password"] = restore_auth["password"]

    resource_graph = checkpoint.resource_graph
    operation_log = utils.create_operation_log_restore(context, restore)
    parameters = restore.parameters
    flow_name = "Restore_" + checkpoint.id
    restore_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_RESTORE,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters
    )

    workflow_engine.add_tasks(
        restore_flow,
        InitiateRestoreTask(),
        CreateHeatTask(inject={'context': context, 'heat_conf': heat_conf}),
        resources_task_flow,
        CreateStackTask(),
        SyncRestoreStatusTask(),
        CompleteRestoreTask()
    )
    flow_engine = workflow_engine.get_engine(
        restore_flow,
        store={
            'context': context,
            'checkpoint': checkpoint,
            'restore': restore,
            'operation_log': operation_log})
    return flow_engine
Ejemplo n.º 11
0
def get_flow(context, workflow_engine, operation_type, checkpoint, provider,
             restore, restore_auth):
    target = restore.get('restore_target', None)

    heat_conf = {}
    if target is not None:
        heat_conf["auth_url"] = target
        if restore_auth is not None:
            auth_type = restore_auth.get("type", None)
            if auth_type == "password":
                heat_conf["username"] = restore_auth["username"]
                heat_conf["password"] = restore_auth["password"]

    resource_graph = checkpoint.resource_graph
    parameters = restore.parameters
    flow_name = "Restore_" + checkpoint.id
    restoration_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=operation_type,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters
    )

    workflow_engine.add_tasks(
        restoration_flow,
        InitiateRestoreTask(),
        CreateHeatTask(inject={'context': context, 'heat_conf': heat_conf}),
        resources_task_flow,
        CreateStackTask(),
        SyncRestoreStatusTask(),
        CompleteRestoreTask()
    )
    flow_engine = workflow_engine.get_engine(restoration_flow,
                                             store={'checkpoint': checkpoint,
                                                    'restore': restore})
    return flow_engine
Ejemplo n.º 12
0
def get_flow(context, protectable_registry, workflow_engine, plan, provider,
             checkpoint, checkpoint_copy):
    resources = set(Resource(**item) for item in plan.get("resources"))
    resource_graph = protectable_registry.build_graph(context, resources)
    checkpoint_copy.resource_graph = resource_graph
    checkpoint_copy.commit()
    operation_log = utils.create_operation_log(context, checkpoint_copy,
                                               constants.OPERATION_COPY)
    flow_name = "Copy_" + plan.get('id') + checkpoint.id
    copy_flow = workflow_engine.build_flow(flow_name, 'linear')
    plugins = provider.load_plugins()
    parameters = {}
    parameters.update(plan.get('parameters', {}))
    parameters['checkpoint'] = checkpoint
    parameters['checkpoint_copy'] = checkpoint_copy
    parameters['operation_log'] = operation_log
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=constants.OPERATION_COPY,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=parameters,
    )
    store_dict = {
        'context': context,
        'checkpoint': checkpoint,
        'checkpoint_copy': checkpoint_copy,
        'operation_log': operation_log
    }
    workflow_engine.add_tasks(
        copy_flow,
        InitiateCopyTask(name='InitiateCopyTask_' + checkpoint_copy.id,
                         inject=store_dict),
        resources_task_flow,
        CompleteCopyTask(name='CompleteCopyTask_' + checkpoint_copy.id,
                         inject=store_dict),
    )
    return copy_flow
Ejemplo n.º 13
0
def get_flow(context, workflow_engine, operation_type, checkpoint, provider):
    LOG.info(_LI("Start get checkpoint flow, checkpoint_id: %s"),
             checkpoint.id)
    flow_name = "Delete_Checkpoint_" + checkpoint.id
    delete_flow = workflow_engine.build_flow(flow_name, 'linear')
    resource_graph = checkpoint.resource_graph
    plugins = provider.load_plugins()
    resources_task_flow = resource_flow.build_resource_flow(
        operation_type=operation_type,
        context=context,
        workflow_engine=workflow_engine,
        resource_graph=resource_graph,
        plugins=plugins,
        parameters=None
    )
    workflow_engine.add_tasks(
        delete_flow,
        InitiateDeleteTask(),
        resources_task_flow,
        CompleteDeleteTask(),
    )
    flow_engine = workflow_engine.get_engine(delete_flow,
                                             store={'checkpoint': checkpoint})
    return flow_engine