Пример #1
0
def config_show_cib():
    print("Resources:")
    utils.pcs_options["--all"] = 1
    utils.pcs_options["--full"] = 1
    resource.resource_show([])
    print()
    print("Stonith Devices:")
    resource.resource_show([], True)
    print("Fencing Levels:")
    stonith.stonith_level_show()
    print()

    lib = utils.get_library_wrapper()
    constraint.location_show([])
    modificators = utils.get_modificators()
    order_command.show(lib, [], modificators)
    colocation_command.show(lib, [], modificators)
    ticket_command.show(lib, [], modificators)

    print()
    alert.print_alert_config(lib, [], modificators)

    print()
    del utils.pcs_options["--all"]
    print("Resources Defaults:")
    resource.show_defaults("rsc_defaults", indent=" ")
    print("Operations Defaults:")
    resource.show_defaults("op_defaults", indent=" ")
    print()
    prop.list_property([])
Пример #2
0
def config_show_cib():
    lib = utils.get_library_wrapper()
    modifiers = utils.get_modifiers()

    print("Resources:")
    utils.pcs_options["--all"] = 1
    utils.pcs_options["--full"] = 1
    resource.resource_show([])

    print()
    print("Stonith Devices:")
    resource.resource_show([], True)
    print("Fencing Levels:")
    levels = stonith.stonith_level_config_to_str(
        lib.fencing_topology.get_config())
    if levels:
        print("\n".join(indent(levels, 2)))

    print()
    constraint.location_show([])
    order_command.show(lib, [], modifiers)
    colocation_command.show(lib, [], modifiers)
    ticket_command.show(lib, [], modifiers)

    print()
    alert.print_alert_config(lib, [], modifiers)

    print()
    del utils.pcs_options["--all"]
    print("Resources Defaults:")
    resource.show_defaults("rsc_defaults", indent=" ")
    print("Operations Defaults:")
    resource.show_defaults("op_defaults", indent=" ")
    print()
    prop.list_property([])
Пример #3
0
def constraint_show(lib, argv, modifiers):
    """
    Options:
      * -f - CIB file
      * --full
    """
    location_show(lib, argv, modifiers)
    order_command.show(lib, argv, modifiers)
    colocation_command.show(lib, argv, modifiers)
    ticket_command.show(lib, argv, modifiers)
Пример #4
0
def constraint_show(lib, argv, modifiers):
    """
    Options:
      * --all - print expired constraints
      * -f - CIB file
      * --full
    """
    location_show(lib, argv, modifiers)
    order_command.show(lib, argv, modifiers.get_subset("--full", "-f"))
    colocation_command.show(lib, argv, modifiers.get_subset("--full", "-f"))
    ticket_command.show(lib, argv, modifiers.get_subset("--full", "-f"))
Пример #5
0
def config_show_cib(lib):
    """
    Commandline options:
      * -f - CIB file
    """
    print("Resources:")
    # update of pcs_options will change output of constraint show
    utils.pcs_options["--full"] = 1
    # get latest modifiers object after updating pcs_options
    modifiers = utils.get_input_modifiers()
    resource.resource_config(lib, [], modifiers.get_subset("-f"))

    print()
    print("Stonith Devices:")
    resource.resource_config(
        lib,
        [],
        modifiers.get_subset("-f"),
        stonith=True,
    )
    print("Fencing Levels:")
    levels = stonith.stonith_level_config_to_str(
        lib.fencing_topology.get_config())
    if levels:
        print("\n".join(indent(levels, 2)))

    print()
    constraint.location_show(lib, [], modifiers.get_subset("-f", "--full"))
    order_command.show(lib, [], modifiers.get_subset("-f", "--full"))
    colocation_command.show(lib, [], modifiers.get_subset("-f", "--full"))
    ticket_command.show(lib, [], modifiers.get_subset("-f", "--full"))

    print()
    alert.print_alert_config(lib, [], modifiers.get_subset("-f"))

    print()
    print("Resources Defaults:")
    resource.show_defaults("rsc_defaults", indent=" ")
    print("Operations Defaults:")
    resource.show_defaults("op_defaults", indent=" ")
    print()
    prop.list_property(lib, [],
                       modifiers.get_subset("--defaults", "--all", "-f"))
Пример #6
0
def constraint_cmd(lib, argv, modifiers):
    if not argv:
        argv = ["list"]
    sub_cmd = argv.pop(0)

    try:
        if sub_cmd == "help":
            usage.constraint(argv)
        elif sub_cmd == "location":
            try:
                if not argv:
                    sub_cmd2 = "show"
                else:
                    sub_cmd2 = argv.pop(0)

                if sub_cmd2 == "add":
                    location_add(lib, argv, modifiers)
                elif sub_cmd2 in ["remove", "delete"]:
                    location_remove(lib, argv, modifiers)
                elif sub_cmd2 == "show":
                    location_show(lib, argv, modifiers)
                elif len(argv) >= 2:
                    if argv[0] == "rule":
                        location_rule(lib, [sub_cmd2] + argv, modifiers)
                    else:
                        location_prefer(lib, [sub_cmd2] + argv, modifiers)
                else:
                    raise CmdLineInputError()
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint",
                                                   f"location {sub_cmd2}")
        elif sub_cmd == "order":
            if not argv:
                sub_cmd2 = "show"
            else:
                sub_cmd2 = argv.pop(0)

            try:
                if sub_cmd2 == "set":
                    order_command.create_with_set(lib, argv, modifiers)
                elif sub_cmd2 in ["remove", "delete"]:
                    order_rm(lib, argv, modifiers)
                elif sub_cmd2 == "show":
                    order_command.show(lib, argv, modifiers)
                else:
                    order_start(lib, [sub_cmd2] + argv, modifiers)
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint",
                                                   f"order {sub_cmd2}")
        elif sub_cmd == "ticket":
            usage_name = "ticket"
            try:
                command_map = {
                    "set": ticket_command.create_with_set,
                    "add": ticket_command.add,
                    "delete": ticket_command.remove,
                    "remove": ticket_command.remove,
                    "show": ticket_command.show,
                }
                sub_command = argv[0] if argv else "show"
                if sub_command not in command_map:
                    raise CmdLineInputError()
                usage_name = "ticket " + sub_command

                command_map[sub_command](lib, argv[1:], modifiers)
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint", usage_name)

        elif sub_cmd == "colocation":
            if not argv:
                sub_cmd2 = "show"
            else:
                sub_cmd2 = argv.pop(0)

            try:
                if sub_cmd2 == "add":
                    colocation_add(lib, argv, modifiers)
                elif sub_cmd2 in ["remove", "delete"]:
                    colocation_rm(lib, argv, modifiers)
                elif sub_cmd2 == "set":
                    colocation_command.create_with_set(lib, argv, modifiers)
                elif sub_cmd2 == "show":
                    colocation_command.show(lib, argv, modifiers)
                else:
                    raise CmdLineInputError()
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint",
                                                   f"colocation {sub_cmd2}")
        elif sub_cmd in ["remove", "delete"]:
            constraint_rm(lib, argv, modifiers)
        elif sub_cmd in ("show", "list"):
            # all these commands accept -f and --full therefore there is no
            # need to change something here
            location_show(lib, argv, modifiers)
            order_command.show(lib, argv, modifiers)
            colocation_command.show(lib, argv, modifiers)
            ticket_command.show(lib, argv, modifiers)
        elif sub_cmd == "ref":
            constraint_ref(lib, argv, modifiers)
        elif sub_cmd == "rule":
            constraint_rule(lib, argv, modifiers)
        else:
            raise CmdLineInputError()
    except LibraryError as e:
        utils.process_library_reports(e.args)
    except CmdLineInputError as e:
        utils.exit_on_cmdline_input_errror(e, "constraint", sub_cmd)
Пример #7
0
def constraint_cmd(argv):
    lib = utils.get_library_wrapper()
    modificators = utils.get_modificators()
    if len(argv) == 0:
        argv = ["list"]

    sub_cmd = argv.pop(0)
    if (sub_cmd == "help"):
        usage.constraint(argv)
    elif (sub_cmd == "location"):
        if len (argv) == 0:
            sub_cmd2 = "show"
        else:
            sub_cmd2 = argv.pop(0)

        if (sub_cmd2 == "add"):
            location_add(argv)
        elif (sub_cmd2 in ["remove","delete"]):
            location_add(argv,True)
        elif (sub_cmd2 == "show"):
            location_show(argv)
        elif len(argv) >= 2:
            if argv[0] == "rule":
                location_rule([sub_cmd2] + argv)
            else:
                location_prefer([sub_cmd2] + argv)
        else:
            usage.constraint()
            sys.exit(1)
    elif (sub_cmd == "order"):
        if (len(argv) == 0):
            sub_cmd2 = "show"
        else:
            sub_cmd2 = argv.pop(0)

        if (sub_cmd2 == "set"):
            try:
                order_command.create_with_set(lib, argv, modificators)
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint", 'order set')
            except LibraryError as e:
                utils.process_library_reports(e.args)
        elif (sub_cmd2 in ["remove","delete"]):
            order_rm(argv)
        elif (sub_cmd2 == "show"):
            order_command.show(lib, argv, modificators)
        else:
            order_start([sub_cmd2] + argv)
    elif sub_cmd == "ticket":
        usage_name = "ticket"
        try:
            command_map = {
                "set": ticket_command.create_with_set,
                "add": ticket_command.add,
                "show": ticket_command.show,
            }
            sub_command = argv[0] if argv else "show"
            if sub_command not in command_map:
                raise CmdLineInputError()
            usage_name = "ticket "+sub_command

            command_map[sub_command](lib, argv[1:], modificators)
        except LibraryError as e:
            utils.process_library_reports(e.args)
        except CmdLineInputError as e:
            utils.exit_on_cmdline_input_errror(e, "constraint", usage_name)

    elif (sub_cmd == "colocation"):
        if (len(argv) == 0):
            sub_cmd2 = "show"
        else:
            sub_cmd2 = argv.pop(0)

        if (sub_cmd2 == "add"):
            colocation_add(argv)
        elif (sub_cmd2 in ["remove","delete"]):
            colocation_rm(argv)
        elif (sub_cmd2 == "set"):
            try:

                colocation_command.create_with_set(lib, argv, modificators)
            except LibraryError as e:
                utils.process_library_reports(e.args)
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint", "colocation set")
        elif (sub_cmd2 == "show"):
            colocation_command.show(lib, argv, modificators)
        else:
            usage.constraint()
            sys.exit(1)
    elif (sub_cmd in ["remove","delete"]):
        constraint_rm(argv)
    elif (sub_cmd == "show" or sub_cmd == "list"):
        location_show(argv)
        order_command.show(lib, argv, modificators)
        colocation_command.show(lib, argv, modificators)
        ticket_command.show(lib, argv, modificators)
    elif (sub_cmd == "ref"):
        constraint_ref(argv)
    elif (sub_cmd == "rule"):
        constraint_rule(argv)
    else:
        usage.constraint()
        sys.exit(1)
Пример #8
0
def constraint_cmd(argv):
    lib = utils.get_library_wrapper()
    modificators = utils.get_modificators()

    if len(argv) == 0:
        argv = ["list"]
    sub_cmd = argv.pop(0)

    try:
        if (sub_cmd == "help"):
            usage.constraint(argv)
        elif (sub_cmd == "location"):
            if len(argv) == 0:
                sub_cmd2 = "show"
            else:
                sub_cmd2 = argv.pop(0)

            if (sub_cmd2 == "add"):
                location_add(argv)
            elif (sub_cmd2 in ["remove", "delete"]):
                location_add(argv, True)
            elif (sub_cmd2 == "show"):
                location_show(argv)
            elif len(argv) >= 2:
                if argv[0] == "rule":
                    location_rule([sub_cmd2] + argv)
                else:
                    location_prefer([sub_cmd2] + argv)
            else:
                usage.constraint()
                sys.exit(1)
        elif (sub_cmd == "order"):
            if (len(argv) == 0):
                sub_cmd2 = "show"
            else:
                sub_cmd2 = argv.pop(0)

            if (sub_cmd2 == "set"):
                try:
                    order_command.create_with_set(lib, argv, modificators)
                except CmdLineInputError as e:
                    utils.exit_on_cmdline_input_errror(e, "constraint",
                                                       'order set')
                except LibraryError as e:
                    utils.process_library_reports(e.args)
            elif (sub_cmd2 in ["remove", "delete"]):
                order_rm(argv)
            elif (sub_cmd2 == "show"):
                order_command.show(lib, argv, modificators)
            else:
                order_start([sub_cmd2] + argv)
        elif sub_cmd == "ticket":
            usage_name = "ticket"
            try:
                command_map = {
                    "set": ticket_command.create_with_set,
                    "add": ticket_command.add,
                    "remove": ticket_command.remove,
                    "show": ticket_command.show,
                }
                sub_command = argv[0] if argv else "show"
                if sub_command not in command_map:
                    raise CmdLineInputError()
                usage_name = "ticket " + sub_command

                command_map[sub_command](lib, argv[1:], modificators)
            except LibraryError as e:
                utils.process_library_reports(e.args)
            except CmdLineInputError as e:
                utils.exit_on_cmdline_input_errror(e, "constraint", usage_name)

        elif (sub_cmd == "colocation"):
            if (len(argv) == 0):
                sub_cmd2 = "show"
            else:
                sub_cmd2 = argv.pop(0)

            if (sub_cmd2 == "add"):
                colocation_add(argv)
            elif (sub_cmd2 in ["remove", "delete"]):
                colocation_rm(argv)
            elif (sub_cmd2 == "set"):
                try:

                    colocation_command.create_with_set(lib, argv, modificators)
                except LibraryError as e:
                    utils.process_library_reports(e.args)
                except CmdLineInputError as e:
                    utils.exit_on_cmdline_input_errror(e, "constraint",
                                                       "colocation set")
            elif (sub_cmd2 == "show"):
                colocation_command.show(lib, argv, modificators)
            else:
                usage.constraint()
                sys.exit(1)
        elif (sub_cmd in ["remove", "delete"]):
            constraint_rm(argv)
        elif (sub_cmd == "show" or sub_cmd == "list"):
            location_show(argv)
            order_command.show(lib, argv, modificators)
            colocation_command.show(lib, argv, modificators)
            ticket_command.show(lib, argv, modificators)
        elif (sub_cmd == "ref"):
            constraint_ref(argv)
        elif (sub_cmd == "rule"):
            constraint_rule(argv)
        else:
            usage.constraint()
            sys.exit(1)
    except LibraryError as e:
        utils.process_library_reports(e.args)
    except CmdLineInputError as e:
        utils.exit_on_cmdline_input_errror(e, "resource", sub_cmd)