Beispiel #1
0
def _agent_metadata_to_dict(
    agent: ResourceAgentMetadata, describe: bool = False
) -> Dict[str, str]:
    agent_dto = agent.to_dto()
    agent_dict = to_dict(agent_dto)
    del agent_dict["name"]
    agent_dict["name"] = agent.name.full_name
    agent_dict["standard"] = agent.name.standard
    agent_dict["provider"] = agent.name.provider
    agent_dict["type"] = agent.name.type

    agent_dict["actions"] = [
        _action_to_operation(action) for action in agent_dto.actions
    ]
    operations_defaults = {
        "OCF_CHECK_LEVEL": None,
        "automatic": False,
        "on_target": False,
    }
    agent_dict["default_actions"] = (
        [
            operation_dto_to_legacy_dict(op, operations_defaults)
            for op in get_default_operations(agent)
        ]
        if describe
        else []
    )
    return agent_dict
Beispiel #2
0
def _agent_metadata_to_dict(agent: ResourceAgentMetadata,
                            describe: bool = False) -> Dict[str, str]:
    agent_dto = agent.to_dto()
    agent_dict = to_dict(agent_dto)
    del agent_dict["name"]
    agent_dict["name"] = agent.name.full_name
    agent_dict["standard"] = agent.name.standard
    agent_dict["provider"] = agent.name.provider
    agent_dict["type"] = agent.name.type

    agent_dict["actions"] = [
        action_to_operation(action, keep_extra_keys=True)
        for action in agent_dto.actions
    ]
    agent_dict["default_actions"] = (complete_operations_options(
        get_default_operations(agent, keep_extra_keys=True))
                                     if describe else [])
    return agent_dict