cloudify自定义工作流程缺少cloudify_agent运行时信息

时间:2016-06-07 07:12:42

标签: workflow cloudify

我想开发一个名为" backup"在cloudify中使用我自己的插件,但是当我运行该工作流时,出现以下错误

'backup' workflow execution failed: RuntimeError: Workflow failed: Task failed 'script_runner.tasks.run' -> Missing cloudify_agent runtime information. This most likely means that the Compute node never started successfully

我不明白为什么,有人能解决我这个问题吗? 这是我的主要蓝图代码和插件代码

我的主要蓝图

tosca_definitions_version: cloudify_dsl_1_2

imports:
  - plugins/backup.yaml
  - types/types.yaml

node_templates:

  mynode:
    type: cloudify.nodes.Compute
    properties:
      ip: "ip"
      agent_config:
        install_method: none
        user: "user"
        key: "key_uri"

  myapp:
    type: cloudify.nodes.ApplicationModule
    interfaces:
      test_platform_backup:
        backup:
          implementation: scripts/backup.sh
          inputs:
            port: 6969
        post_backup:
          implementation: scripts/post_backup.sh
    relationships:
      - type: cloudify.relationships.contained_in
        target: mynode

我的插件代码:

from cloudify.decorators import workflow
from cloudify.workflows import ctx
from cloudify.workflows.tasks_graph import forkjoin

@workflow
def backup(operation, type_name, operation_kwargs, is_node_operation, **kwargs):
    graph = ctx.graph_mode()

    send_event_starting_tasks = {}
    send_event_done_tasks = {}

    for node in ctx.nodes:
        if type_name in node.type_hierarchy:
            for instance in node.instances:
                send_event_starting_tasks[instance.id] = instance.send_event('Starting to run operation')
                send_event_done_tasks[instance.id] = instance.send_event('Done running operation')

    for node in ctx.nodes:
        if type_name in node.type_hierarchy:
            for instance in node.instances:

                sequence = graph.sequence()

                if is_node_operation:
                    operation_task = instance.execute_operation(operation, kwargs=operation_kwargs)
                else:
                    forkjoin_tasks = []
                    for relationship in instance.relationships:
                        forkjoin_tasks.append(relationship.execute_source_operation(operation))
                        forkjoin_tasks.append(relationship.execute_target_operation(operation))
                    operation_task = forkjoin(*forkjoin_tasks)

                sequence.add(
                    send_event_starting_tasks[instance.id],
                    operation_task,
                    send_event_done_tasks[instance.id])

    for node in ctx.nodes:
        for instance in node.instances:
            for rel in instance.relationships:

                instance_starting_task = send_event_starting_tasks.get(instance.id)
                target_done_task = send_event_done_tasks.get(rel.target_id)

                if instance_starting_task and target_done_task:
                    graph.add_dependency(instance_starting_task, target_done_task)

    return graph.execute()

1 个答案:

答案 0 :(得分:2)

您的虚拟机似乎没有启动。

从你的代码中我无法理解你想要做什么。 您没有安装和代理,并且您没有与VM的结构连接,但您正在尝试在VM上运行操作。

您应该安装代理,例如删除“install_method:none”,或者将虚拟机连接添加到虚拟机并使用它运行操作。