Пример #1
0
def tag_update(
    lib: Any,
    argv: Sequence[str],
    modifiers: InputModifiers,
) -> None:
    """
    Options:
      * -f - CIB file
      * --after - place a reference id in a tag after the specified reference
        id in the tag
      * --before - place a reference id in a tag before the specified reference
        id in the tag
    """
    modifiers.ensure_only_supported("-f", "--after", "--before")
    if not argv:
        raise CmdLineInputError()
    tag_id = argv[0]
    parsed_args = group_by_keywords(
        argv[1:],
        ["add", "remove"],
        keyword_repeat_allowed=False,
        only_found_keywords=True,
    )
    no_add_remove_arguments = ("add" not in parsed_args
                               and "remove" not in parsed_args)
    no_add_id = "add" in parsed_args and not parsed_args["add"]
    no_remove_id = "remove" in parsed_args and not parsed_args["remove"]
    if no_add_remove_arguments or no_add_id or no_remove_id:
        raise CmdLineInputError(
            show_both_usage_and_message=True,
            hint=("Specify at least one id for 'add' or 'remove' arguments."),
        )
    adjacent_idref = None
    after_adjacent = True
    if modifiers.is_specified("--after") and modifiers.is_specified(
            "--before"):
        raise CmdLineInputError("Cannot specify both --before and --after")
    if modifiers.is_specified("--after"):
        adjacent_idref = modifiers.get("--after")
        after_adjacent = True
    elif modifiers.is_specified("--before"):
        adjacent_idref = modifiers.get("--before")
        after_adjacent = False
    lib.tag.update(
        tag_id,
        parsed_args["add"] if "add" in parsed_args else [],
        parsed_args["remove"] if "remove" in parsed_args else [],
        adjacent_idref=adjacent_idref,
        put_after_adjacent=after_adjacent,
    )
Пример #2
0
def stonith_list_options(lib: Any, argv: List[str],
                         modifiers: parse_args.InputModifiers) -> None:
    """
    Options:
      * --full - show advanced options
    """
    modifiers.ensure_only_supported("--full")
    if len(argv) != 1:
        raise CmdLineInputError()
    agent_name = ResourceAgentNameDto("stonith", None, argv[0])
    print("\n".join(
        smart_wrap_text(
            resource_agent_metadata_to_text(
                lib.resource_agent.get_agent_metadata(agent_name),
                lib.resource_agent.get_agent_default_operations(
                    agent_name).operations,
                verbose=modifiers.is_specified("--full"),
            ))))