def resource_op_defaults_cmd(lib: Any, argv: List[str], modifiers: InputModifiers) -> None: """ Options: * -f - CIB file * --force - allow unknown options """ if argv and "=" in argv[0]: # DEPRECATED legacy command return resource.resource_op_defaults_legacy_cmd( lib, argv, modifiers, deprecated_syntax_used=True) router = create_router( { "config": resource.resource_op_defaults_config_cmd, "set": create_router( { "create": resource.resource_op_defaults_set_create_cmd, "delete": resource.resource_op_defaults_set_remove_cmd, "remove": resource.resource_op_defaults_set_remove_cmd, "update": resource.resource_op_defaults_set_update_cmd, }, ["resource", "op", "defaults", "set"], ), "update": resource.resource_op_defaults_legacy_cmd, }, ["resource", "op", "defaults"], default_cmd="config", ) return router(lib, argv, modifiers)
def config_cmd(lib, argv, modifiers): create_router( { "help": lambda _lib, _argv, _modifiers: usage.config(_argv), "show": config_show, "backup": config_backup, "restore": config_restore, "checkpoint": create_router( { "list": config_checkpoint_list, "view": config_checkpoint_view, "restore": config_checkpoint_restore, "diff": config_checkpoint_diff, }, ["config", "checkpoint"], default_cmd="list"), "import-cman": config_import_cman, "export": create_router( { "pcs-commands": config_export_pcs_commands, "pcs-commands-verbose": lambda _lib, _argv, _modifiers: config_export_pcs_commands( _lib, _argv, _modifiers, verbose=True) }, ["config", "export"]) }, ["config"], default_cmd="show", )(lib, argv, modifiers)
def booth_cmd(lib, argv, modifiers): try: create_router( { "help": lambda _lib, _argv, _modifiers: usage.booth(_argv), "config": command.config_show, "setup": command.config_setup, "destroy": command.config_destroy, "ticket": create_router( { "help": lambda _lib, _argv, _modifiers: usage.booth(["ticket"] ), "add": command.config_ticket_add, "delete": command.config_ticket_remove, "remove": command.config_ticket_remove, "grant": command.ticket_grant, "revoke": command.ticket_revoke, }, ["booth", "ticket"]), "create": command.create_in_cluster, "delete": command.get_remove_from_cluster(resource_remove), "remove": command.get_remove_from_cluster(resource_remove), "restart": command.get_restart(resource_restart), "sync": command.sync, "pull": command.pull, "enable": command.enable, "disable": command.disable, "start": command.start, "stop": command.stop, "status": command.status, }, ["booth"])(lib, argv, modifiers) except CmdLineInputError as e: utils.exit_on_cmdline_input_errror(e, "booth", "")
def status_cmd(lib, argv, modifiers): create_router( { "help": lambda _lib, _argv, _modifiers: usage.status(_argv), "booth": booth_status_cmd, "corosync": corosync_status, "cluster": cluster_status, "nodes": nodes_status, "pcsd": cluster_pcsd_status, "qdevice": qdevice_status_cmd, "quorum": quorum_status_cmd, "resources": resource.resource_status, "xml": xml_status, "status": full_status, }, ["status"], default_cmd="status", )(lib, argv, modifiers)
def alert_cmd(lib, argv, modifiers): create_router( { "help": lambda _lib, _argv, _modifiers: usage.alert(_argv), "create": alert_add, "update": alert_update, "delete": alert_remove, "remove": alert_remove, "config": print_alert_config, "show": print_alert_config, "recipient": create_router( { "help": lambda _lib, _argv, _modifiers: usage.alert(["recipient"]), "add": recipient_add, "update": recipient_update, "delete": recipient_remove, "remove": recipient_remove, }, ["alert", "recipient"], ), "get_all_alerts": print_alerts_in_json, }, ["alert"], default_cmd="config", )(lib, argv, modifiers)
def main(argv=None): # pylint: disable=too-many-locals, too-many-branches, too-many-statements, global-statement if completion.has_applicable_environment(os.environ): print(completion.make_suggestions( os.environ, usage.generate_completion_tree_from_usage() )) sys.exit() argv = argv if argv else sys.argv[1:] utils.subprocess_setup() global filename, usefile utils.pcs_options = {} # we want to support optional arguments for --wait, so if an argument # is specified with --wait (ie. --wait=30) then we use them waitsecs = None new_argv = [] for arg in argv: if arg.startswith("--wait="): tempsecs = arg.replace("--wait=", "") if tempsecs: waitsecs = tempsecs arg = "--wait" new_argv.append(arg) argv = new_argv try: pcs_options, dummy_argv = getopt.gnu_getopt( parse_args.filter_out_non_option_negative_numbers(argv), parse_args.PCS_SHORT_OPTIONS, parse_args.PCS_LONG_OPTIONS, ) except getopt.GetoptError as err: print(err) usage.main() sys.exit(1) argv = parse_args.filter_out_options(argv) full = False for option, dummy_value in pcs_options: if option == "--full": full = True break for opt, val in pcs_options: if not opt in utils.pcs_options: utils.pcs_options[opt] = val else: # If any options are a list then they've been entered twice which # isn't valid utils.err("%s can only be used once" % opt) if opt in ("-h", "--help"): if not argv: usage.main() sys.exit() else: argv = [argv[0], "help"] + argv[1:] elif opt == "-f": usefile = True filename = val utils.usefile = usefile utils.filename = filename elif opt == "--corosync_conf": settings.corosync_conf_file = val elif opt == "--version": print(settings.pcs_version) if full: print(" ".join( sorted([ feat["id"] for feat in capabilities.get_pcs_capabilities() ]) )) sys.exit() elif opt == "--fullhelp": usage.full_usage() sys.exit() elif opt == "--wait": utils.pcs_options[opt] = waitsecs elif opt == "--request-timeout": request_timeout_valid = False try: timeout = int(val) if timeout > 0: utils.pcs_options[opt] = timeout request_timeout_valid = True except ValueError: pass if not request_timeout_valid: utils.err( ( "'{0}' is not a valid --request-timeout value, use " "a positive integer" ).format(val) ) logger = logging.getLogger("pcs") logger.propagate = 0 logger.handlers = [] if (os.getuid() != 0) and (argv and argv[0] != "help") and not usefile: non_root_run(argv) cmd_map = { "resource": resource.resource_cmd, "cluster": cluster.cluster_cmd, "stonith": stonith.stonith_cmd, "property": prop.property_cmd, "constraint": constraint.constraint_cmd, "acl": acl.acl_cmd, "status": status.status_cmd, "config": config.config_cmd, "pcsd": pcsd.pcsd_cmd, "node": node.node_cmd, "quorum": quorum.quorum_cmd, "qdevice": qdevice.qdevice_cmd, "alert": alert.alert_cmd, "booth": booth.booth_cmd, "host": host.host_cmd, "client": client.client_cmd, "help": lambda lib, argv, modifiers: usage.main(), } try: routing.create_router(cmd_map, [])( utils.get_library_wrapper(), argv, utils.get_input_modifiers() ) except LibraryError as e: utils.process_library_reports(e.args) except errors.CmdLineInputError: if argv and argv[0] in cmd_map: usage.show(argv[0], []) else: usage.main() sys.exit(1)
from pcs import ( status, usage, ) from pcs.cli.common.routing import create_router from pcs.qdevice import qdevice_status_cmd from pcs.quorum import quorum_status_cmd from pcs.resource import resource_status from pcs.cli.booth.command import status as booth_status_cmd status_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.status(argv), "booth": booth_status_cmd, "corosync": status.corosync_status, "cluster": status.cluster_status, "nodes": status.nodes_status, "pcsd": status.cluster_pcsd_status, "qdevice": qdevice_status_cmd, "quorum": quorum_status_cmd, "resources": resource_status, "xml": status.xml_status, "status": status.full_status, }, ["status"], default_cmd="status", )
from pcs import usage from pcs.cli.common.routing import create_router from pcs.cli.tag import command as tag tag_cmd = create_router( { "config": tag.tag_config, "create": tag.tag_create, "delete": tag.tag_remove, "help": lambda lib, argv, modifiers: print(usage.tag(argv)), # TODO remove, deprecated command # replaced with 'config' "list": tag.tag_list_cmd, "remove": tag.tag_remove, "update": tag.tag_update, }, ["tag"], default_cmd="config", )
resource_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.resource(argv), "list": resource.resource_list_available, "describe": resource.resource_list_options, "create": resource.resource_create, "move": resource.resource_move, "ban": resource.resource_ban, "clear": resource.resource_unmove_unban, "standards": resource.resource_standards, "providers": resource.resource_providers, "agents": resource.resource_agents, "update": resource.resource_update, "meta": resource.resource_meta, "delete": resource.resource_remove_cmd, "remove": resource.resource_remove_cmd, # TODO remove, deprecated command # replaced with 'resource status' and 'resource config' "show": resource.resource_show, "status": resource.resource_status, "config": resource.resource_config, "group": create_router( { "add": resource.resource_group_add_cmd, "list": resource.resource_group_list, "remove": resource.resource_group_rm_cmd, "delete": resource.resource_group_rm_cmd, }, ["resource", "group"], ), "ungroup": resource.resource_group_rm_cmd, "clone": resource.resource_clone, "promotable": partial(resource.resource_clone, promotable=True), "unclone": resource.resource_clone_master_remove, "enable": resource.resource_enable_cmd, "disable": resource.resource_disable_cmd, "restart": resource.resource_restart, "debug-start": partial( resource.resource_force_action, action="debug-start" ), "debug-stop": partial( resource.resource_force_action, action="debug-stop" ), "debug-promote": partial( resource.resource_force_action, action="debug-promote" ), "debug-demote": partial( resource.resource_force_action, action="debug-demote" ), "debug-monitor": partial( resource.resource_force_action, action="debug-monitor" ), "manage": resource.resource_manage_cmd, "unmanage": resource.resource_unmanage_cmd, "failcount": resource.resource_failcount, "op": create_router( { "defaults": resource.resource_op_defaults_cmd, "add": resource.resource_op_add_cmd, "remove": resource.resource_op_delete_cmd, "delete": resource.resource_op_delete_cmd, }, ["resource", "op"] ), "defaults": resource.resource_defaults_cmd, "cleanup": resource.resource_cleanup, "refresh": resource.resource_refresh, "relocate": create_router( { "show": resource.resource_relocate_show_cmd, "dry-run": resource.resource_relocate_dry_run_cmd, "run": resource.resource_relocate_run_cmd, "clear": resource.resource_relocate_clear_cmd, }, ["resource", "relocate"] ), "utilization": resource.resource_utilization_cmd, "bundle": create_router( { "create": resource.resource_bundle_create_cmd, "reset": resource.resource_bundle_reset_cmd, "update": resource.resource_bundle_update_cmd, }, ["resource", "bundle"] ), # internal use only "get_resource_agent_info": resource.get_resource_agent_info, # removed commands # These print error messages which point users to the changes section in # pcs manpage. # To be removed in the next significant version. "master": lambda lib, argv, modifiers: raise_command_replaced( "pcs resource promotable" ), "relations": show_resource_relations_cmd, }, ["resource"], default_cmd="status" )
alert, usage, ) from pcs.cli.common.routing import create_router alert_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.alert(argv), "create": alert.alert_add, "update": alert.alert_update, "delete": alert.alert_remove, "remove": alert.alert_remove, "config": alert.print_alert_config, "show": alert.print_alert_config, "recipient": create_router( { "help": lambda lib, argv, modifiers: usage.alert(["recipient"]), "add": alert.recipient_add, "update": alert.recipient_update, "delete": alert.recipient_remove, "remove": alert.recipient_remove, }, ["alert", "recipient"], ), "get_all_alerts": alert.print_alerts_in_json, }, ["alert"], default_cmd="config", )
stonith_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.stonith(argv), "list": stonith.stonith_list_available, "describe": stonith.stonith_list_options, "create": stonith.stonith_create, "update": resource.resource_update, "delete": resource.resource_remove_cmd, "remove": resource.resource_remove_cmd, # TODO remove, deprecated command # replaced with 'stonith status' and 'stonith config' "show": stonith.stonith_show_cmd, "status": stonith.stonith_status_cmd, "config": stonith.stonith_config_cmd, "level": create_router( { "add": stonith.stonith_level_add_cmd, "clear": stonith.stonith_level_clear_cmd, "config": stonith.stonith_level_config_cmd, "remove": stonith.stonith_level_remove_cmd, "delete": stonith.stonith_level_remove_cmd, "verify": stonith.stonith_level_verify_cmd, }, ["stonith", "level"], default_cmd="config" ), "fence": stonith.stonith_fence, "cleanup": resource.resource_cleanup, "refresh": resource.resource_refresh, "confirm": stonith.stonith_confirm, "sbd": create_router( { "enable": stonith.sbd_enable, "disable": stonith.sbd_disable, "status": stonith.sbd_status, "config": stonith.sbd_config, "device": create_router( { "setup": stonith.sbd_setup_block_device, "message": stonith.sbd_message, }, ["stonith", "sbd", "device"] ), "watchdog": create_router( { "list": stonith.sbd_watchdog_list, "test": stonith.sbd_watchdog_test, # internal use only "list_json": stonith.sbd_watchdog_list_json, }, ["stonith", "sbd", "watchdog"] ), # internal use only "local_config_in_json": stonith.local_sbd_config, }, ["stonith", "sbd"] ), "enable": resource.resource_enable_cmd, "disable": resource.resource_disable_cmd, "history": create_router( { "show": stonith.stonith_history_show_cmd, "cleanup": stonith.stonith_history_cleanup_cmd, "update": stonith.stonith_history_update_cmd, }, ["stonith", "history"], default_cmd="show" ), # internal use only "get_fence_agent_info": stonith.get_fence_agent_info, }, ["stonith"], default_cmd="status" )
from pcs import ( prop, usage, ) from pcs.cli.common.routing import create_router property_cmd = create_router( { "help": lambda _lib, _argv, _modifiers: usage.property(_argv), "set": prop.set_property, "unset": prop.unset_property, # TODO remove, deprecated command # replaced with 'config' "list": prop.list_property_deprecated, # TODO remove, deprecated command # replaced with 'config' "show": prop.list_property_deprecated, "config": prop.list_property, "get_cluster_properties_definition": (prop.print_cluster_properties_definition), }, ["property"], default_cmd="config", )
cluster_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.cluster(argv), "setup": cluster.cluster_setup, "config": create_router( { "show": cluster.config_show, "update": cluster.config_update, }, ["cluster", "config"], default_cmd="show", ), "authkey": create_router( {"corosync": cluster.authkey_corosync}, ["cluster", "authkey"], ), "sync": create_router( { "corosync": cluster.sync_nodes, }, ["cluster", "sync"], default_cmd="corosync", ), "status": status.cluster_status, # TODO remove, deprecated command # replaced with 'pcs pcsd status' and 'pcs status pcsd' "pcsd-status": pcsd_status, # TODO remove, deprecated command # replaced with 'pcs pcsd certkey' "certkey": certkey, "auth": cluster.cluster_auth_cmd, "start": cluster.cluster_start_cmd, "stop": cluster.cluster_stop_cmd, "kill": cluster.kill_cluster, "enable": cluster.cluster_enable_cmd, "disable": cluster.cluster_disable_cmd, "cib": cluster.get_cib, "cib-push": cluster.cluster_push, "cib-upgrade": cluster.cluster_cib_upgrade_cmd, "edit": cluster.cluster_edit, "link": create_router( { "add": cluster.link_add, "delete": cluster.link_remove, "remove": cluster.link_remove, "update": cluster.link_update, }, ["cluster", "link"], ), "node": create_router( { "add": cluster.node_add, "add-guest": cluster_command.node_add_guest, "add-outside": cluster.node_add_outside_cluster, "add-remote": cluster_command.node_add_remote, "clear": cluster_command.node_clear, "delete": cluster.node_remove, "delete-guest": cluster_command.node_remove_guest, "delete-remote": cluster_command.create_node_remove_remote( resource.resource_remove), "remove": cluster.node_remove, "remove-guest": cluster_command.node_remove_guest, "remove-remote": cluster_command.create_node_remove_remote( resource.resource_remove), }, ["cluster", "node"], ), "uidgid": cluster.cluster_uidgid, "corosync": cluster.cluster_get_corosync_conf, "reload": cluster.cluster_reload, "destroy": cluster.cluster_destroy, "verify": cluster.cluster_verify, "report": cluster.cluster_report, "remove_nodes_from_cib": cluster.remove_nodes_from_cib, # removed commands # These print error messages which point users to the changes section in # pcs manpage. # To be removed in the next significant version. "quorum": lambda lib, argv, modifiers: raise_command_replaced("pcs quorum"), "remote-node": create_router( { "add": lambda lib, argv, modifiers: raise_command_replaced( "pcs cluster node add-guest", ), "remove": lambda lib, argv, modifiers: raise_command_replaced( "pcs cluster node delete-guest", "pcs cluster node remove-guest", ), }, ["cluster", "node"], ), "standby": lambda lib, argv, modifiers: raise_command_replaced("pcs node standby" ), "unstandby": lambda lib, argv, modifiers: raise_command_replaced( "pcs node unstandby"), }, ["cluster"], )
constraint_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.constraint(argv)), "location": constraint.constraint_location_cmd, "order": constraint.constraint_order_cmd, "ticket": create_router( { "set": ticket_command.create_with_set, "add": ticket_command.add, "delete": ticket_command.remove, "remove": ticket_command.remove, # TODO remove, deprecated command # replaced with 'config' "show": ticket_command.show, "config": ticket_command.config_cmd, }, ["constraint", "ticket"], default_cmd="config", ), "colocation": create_router( { "add": constraint.colocation_add, "remove": constraint.colocation_rm, "delete": constraint.colocation_rm, "set": colocation_command.create_with_set, # TODO remove, deprecated command # replaced with 'config' "show": colocation_command.show, "config": colocation_command.config_cmd, }, ["constraint", "colocation"], default_cmd="config", ), "remove": constraint.constraint_rm, "delete": constraint.constraint_rm, # TODO remove, deprecated command # replaced with 'config' "show": constraint.constraint_show, # TODO remove, deprecated command # replaced with 'config' "list": constraint.constraint_show, "config": constraint.constraint_config_cmd, "ref": constraint.constraint_ref, "rule": constraint.constraint_rule, }, ["constraint"], default_cmd="config", )
alert_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.alert(argv)), "create": alert.alert_add, "update": alert.alert_update, "delete": alert.alert_remove, "remove": alert.alert_remove, "config": alert.print_alert_config, # TODO remove, deprecated command # replaced with 'config' "show": alert.print_alert_show, "recipient": create_router( { "help": lambda lib, argv, modifiers: print(usage.alert(["recipient"])), "add": alert.recipient_add, "update": alert.recipient_update, "delete": alert.recipient_remove, "remove": alert.recipient_remove, }, ["alert", "recipient"], ), "get_all_alerts": alert.print_alerts_in_json, }, ["alert"], default_cmd="config", )
from pcs import usage from pcs.cli import dr from pcs.cli.common.routing import create_router dr_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.dr(argv)), "config": dr.config, "destroy": dr.destroy, "set-recovery-site": dr.set_recovery_site, "status": dr.status, }, ["dr"], )
from pcs import ( prop, usage, ) from pcs.cli.common.routing import create_router property_cmd = create_router( { "help": lambda _lib, _argv, _modifiers: usage.property(_argv), "set": prop.set_property, "unset": prop.unset_property, "list": prop.list_property, "show": prop.list_property, "get_cluster_properties_definition": prop.print_cluster_properties_definition, }, ["property"], default_cmd="list" )
def main(argv=None): # pylint: disable=global-statement # pylint: disable=too-many-branches # pylint: disable=too-many-locals # pylint: disable=too-many-statements if completion.has_applicable_environment(os.environ): print( completion.make_suggestions( os.environ, usage.generate_completion_tree_from_usage() ) ) sys.exit() argv = argv if argv else sys.argv[1:] utils.subprocess_setup() global filename, usefile utils.pcs_options = {} # we want to support optional arguments for --wait, so if an argument # is specified with --wait (ie. --wait=30) then we use them waitsecs = None new_argv = [] for arg in argv: if arg.startswith("--wait="): tempsecs = arg.replace("--wait=", "") if tempsecs: waitsecs = tempsecs arg = "--wait" new_argv.append(arg) argv = new_argv try: if "--" in argv: pcs_options, argv = getopt.gnu_getopt( argv, parse_args.PCS_SHORT_OPTIONS, parse_args.PCS_LONG_OPTIONS ) else: # DEPRECATED # TODO remove # We want to support only the -- version ( args_without_negative_nums, args_filtered_out, ) = parse_args.filter_out_non_option_negative_numbers(argv) if args_filtered_out: options_str = "', '".join(args_filtered_out) output.warn( f"Using '{options_str}' without '--' is deprecated, those " "parameters will be considered position independent " "options in future pcs versions" ) pcs_options, dummy_argv = getopt.gnu_getopt( args_without_negative_nums, parse_args.PCS_SHORT_OPTIONS, parse_args.PCS_LONG_OPTIONS, ) argv = parse_args.filter_out_options(argv) except getopt.GetoptError as err: usage.main() print(err) if err.opt in {"V", "clone", "device", "watchdog"}: # Print error messages which point users to the changes section in # pcs manpage. # TODO remove # To be removed in the next significant version. print(f"Hint: {errors.HINT_SYNTAX_CHANGE}") sys.exit(1) full = False for option, dummy_value in pcs_options: if option == "--full": full = True break for opt, val in pcs_options: if not opt in utils.pcs_options: utils.pcs_options[opt] = val else: # If any options are a list then they've been entered twice which # isn't valid utils.err("%s can only be used once" % opt) if opt in ("-h", "--help"): if not argv: usage.main() sys.exit() else: argv = [argv[0], "help"] + argv[1:] elif opt == "-f": usefile = True filename = val utils.usefile = usefile utils.filename = filename elif opt == "--corosync_conf": settings.corosync_conf_file = val elif opt == "--version": print(settings.pcs_version) if full: print( " ".join( sorted( [ feat["id"] for feat in capabilities.get_pcs_capabilities() ] ) ) ) sys.exit() elif opt == "--fullhelp": usage.full_usage() sys.exit() elif opt == "--wait": utils.pcs_options[opt] = waitsecs elif opt == "--request-timeout": request_timeout_valid = False try: timeout = int(val) if timeout > 0: utils.pcs_options[opt] = timeout request_timeout_valid = True except ValueError: pass if not request_timeout_valid: utils.err( ( "'{0}' is not a valid --request-timeout value, use " "a positive integer" ).format(val) ) logger = logging.getLogger("pcs") logger.propagate = 0 logger.handlers = [] if (os.getuid() != 0) and (argv and argv[0] != "help") and not usefile: _non_root_run(argv) cmd_map = { "resource": resource.resource_cmd, "cluster": cluster.cluster_cmd, "stonith": stonith.stonith_cmd, "property": prop.property_cmd, "constraint": constraint.constraint_cmd, "acl": acl.acl_cmd, "status": status.status_cmd, "config": config.config_cmd, "pcsd": pcsd.pcsd_cmd, "node": node.node_cmd, "quorum": quorum.quorum_cmd, "qdevice": qdevice.qdevice_cmd, "alert": alert.alert_cmd, "booth": booth.booth_cmd, "host": host.host_cmd, "client": client.client_cmd, "dr": dr.dr_cmd, "tag": tag.tag_cmd, "help": lambda lib, argv, modifiers: usage.main(), } try: routing.create_router(cmd_map, [])( utils.get_library_wrapper(), argv, utils.get_input_modifiers() ) except LibraryError as e: process_library_reports(e.args) except errors.CmdLineInputError: if argv and argv[0] in cmd_map: usage.show(argv[0], []) else: usage.main() sys.exit(1)
stonith_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.stonith(argv)), "list": stonith.stonith_list_available, "describe": stonith.stonith_list_options, "config": stonith.config_cmd, "create": stonith.stonith_create, "update": stonith.update_cmd, "update-scsi-devices": stonith.stonith_update_scsi_devices, "delete": stonith.delete_cmd, "remove": stonith.delete_cmd, # TODO remove, deprecated command # replaced with 'stonith status' and 'stonith config' "show": stonith.stonith_show_cmd, "status": stonith.stonith_status_cmd, "meta": stonith.meta_cmd, "op": create_router( { "defaults": resource_op_defaults_cmd(["resource", "op", "defaults"]), "add": stonith.op_add_cmd, "remove": stonith.op_delete_cmd, "delete": stonith.op_delete_cmd, }, ["stonith", "op"], ), "defaults": resource_defaults_cmd(["resource", "defaults"]), "level": create_router( { "add": stonith.stonith_level_add_cmd, "clear": stonith.stonith_level_clear_cmd, "config": stonith.stonith_level_config_cmd, "remove": stonith.stonith_level_remove_cmd, "delete": stonith.stonith_level_remove_cmd, "verify": stonith.stonith_level_verify_cmd, }, ["stonith", "level"], default_cmd="config", ), "failcount": create_router( { "show": resource.resource_failcount_show, }, ["stonith", "failcount"], default_cmd="show", ), "fence": stonith.stonith_fence, "cleanup": resource.resource_cleanup, "refresh": resource.resource_refresh, "confirm": stonith.stonith_confirm, "sbd": create_router( { "enable": stonith.sbd_enable, "disable": stonith.sbd_disable, "status": stonith.sbd_status, "config": stonith.sbd_config, "device": create_router( { "setup": stonith.sbd_setup_block_device, "message": stonith.sbd_message, }, ["stonith", "sbd", "device"], ), "watchdog": create_router( { "list": stonith.sbd_watchdog_list, "test": stonith.sbd_watchdog_test, # internal use only "list_json": stonith.sbd_watchdog_list_json, }, ["stonith", "sbd", "watchdog"], ), # internal use only "local_config_in_json": stonith.local_sbd_config, }, ["stonith", "sbd"], ), "enable": stonith.enable_cmd, "disable": stonith.disable_cmd, "history": create_router( { "show": stonith.stonith_history_show_cmd, "cleanup": stonith.stonith_history_cleanup_cmd, "update": stonith.stonith_history_update_cmd, }, ["stonith", "history"], default_cmd="show", ), # internal use only "get_fence_agent_info": stonith.get_fence_agent_info, }, ["stonith"], default_cmd="status", )
acl_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.acl(argv), "show": acl.show_acl_config, "enable": acl.acl_enable, "disable": acl.acl_disable, "role": create_router( { "create": acl.role_create, "delete": acl.role_delete, "remove": acl.role_delete, "assign": acl.role_assign, "unassign": acl.role_unassign, }, ["acl", "role"], ), "user": create_router( { "create": acl.user_create, "delete": acl.user_delete, "remove": acl.user_delete, }, ["acl", "user"]), "group": create_router( { "create": acl.group_create, "delete": acl.group_delete, "remove": acl.group_delete, }, ["acl", "group"]), "permission": create_router( { "add": acl.permission_add, "delete": acl.run_permission_delete, "remove": acl.run_permission_delete, }, ["acl", "permission"]), }, ["acl"], default_cmd="show")
acl_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.acl(argv), "show": acl.show_acl_config, "enable": acl.acl_enable, "disable": acl.acl_disable, "role": create_router( { "create": acl.role_create, "delete": acl.role_delete, "remove": acl.role_delete, "assign": acl.role_assign, "unassign": acl.role_unassign, }, ["acl", "role"], ), "user": create_router( { "create": acl.user_create, "delete": acl.user_delete, "remove": acl.user_delete, }, ["acl", "user"] ), "group": create_router( { "create": acl.group_create, "delete": acl.group_delete, "remove": acl.group_delete, }, ["acl", "group"] ), "permission": create_router( { "add": acl.permission_add, "delete": acl.run_permission_delete, "remove": acl.run_permission_delete, }, ["acl", "permission"] ), }, ["acl"], default_cmd="show" )
from pcs import client from pcs.cli.common.routing import create_router client_cmd = create_router( { "local-auth": client.local_auth_cmd, }, ["client"], )
cluster_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.cluster(argv)), "setup": cluster.cluster_setup, "config": create_router( { "show": cluster.config_show, "update": cluster.config_update, }, ["cluster", "config"], default_cmd="show", ), "authkey": create_router( {"corosync": cluster.authkey_corosync}, ["cluster", "authkey"], ), "sync": create_router( { "corosync": cluster.sync_nodes, }, ["cluster", "sync"], default_cmd="corosync", ), "status": status.cluster_status, # TODO remove, deprecated command # replaced with 'pcs pcsd status' and 'pcs status pcsd' "pcsd-status": pcsd_status, # TODO remove, deprecated command # replaced with 'pcs pcsd certkey' "certkey": certkey, "auth": cluster.cluster_auth_cmd, "start": cluster.cluster_start_cmd, "stop": cluster.cluster_stop_cmd, "kill": cluster.kill_cluster, "enable": cluster.cluster_enable_cmd, "disable": cluster.cluster_disable_cmd, "cib": cluster.get_cib, "cib-push": cluster.cluster_push, "cib-upgrade": cluster.cluster_cib_upgrade_cmd, "edit": cluster.cluster_edit, "link": create_router( { "add": cluster.link_add, "delete": cluster.link_remove, "remove": cluster.link_remove, "update": cluster.link_update, }, ["cluster", "link"], ), "node": create_router( { "add": cluster.node_add, "add-guest": cluster_command.node_add_guest, "add-outside": cluster.node_add_outside_cluster, "add-remote": cluster_command.node_add_remote, "clear": cluster_command.node_clear, "delete": cluster.node_remove, "delete-guest": cluster_command.node_remove_guest, "delete-remote": cluster_command.create_node_remove_remote( resource.resource_remove), "remove": cluster.node_remove, "remove-guest": cluster_command.node_remove_guest, "remove-remote": cluster_command.create_node_remove_remote( resource.resource_remove), }, ["cluster", "node"], ), "uidgid": cluster.cluster_uidgid, "corosync": cluster.cluster_get_corosync_conf, "reload": cluster.cluster_reload, "destroy": cluster.cluster_destroy, "verify": cluster.cluster_verify, "report": cluster.cluster_report, "remove_nodes_from_cib": cluster.remove_nodes_from_cib, }, ["cluster"], )
from pcs import client from pcs.cli.common.routing import create_router client_cmd = create_router( { "local-auth": client.local_auth_cmd, }, ["client"], )
from pcs import usage from pcs.cli.common.routing import create_router from pcs.cli.tag import command as tag tag_cmd = create_router( { "config": tag.tag_config, "create": tag.tag_create, "delete": tag.tag_remove, "help": lambda lib, argv, modifiers: usage.tag(argv), "list": tag.tag_config, "remove": tag.tag_remove, "update": tag.tag_update, }, ["tag"], default_cmd="config", )
constraint_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.constraint(argv), "location": constraint.constraint_location_cmd, "order": constraint.constraint_order_cmd, "ticket": create_router( { "set": ticket_command.create_with_set, "add": ticket_command.add, "delete": ticket_command.remove, "remove": ticket_command.remove, "show": ticket_command.show, }, ["constraint", "ticket"], default_cmd="show" ), "colocation": create_router( { "add": constraint.colocation_add, "remove": constraint.colocation_rm, "delete": constraint.colocation_rm, "set": colocation_command.create_with_set, "show": colocation_command.show, }, ["constraint", "colocation"], default_cmd="show" ), "remove": constraint.constraint_rm, "delete": constraint.constraint_rm, "show": constraint.constraint_show, "list": constraint.constraint_show, "ref": constraint.constraint_ref, "rule": constraint.constraint_rule, }, ["constraint"], default_cmd="list" )
config_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.config(argv), "show": config.config_show, "backup": config.config_backup, "restore": config.config_restore, "checkpoint": create_router( { "list": config.config_checkpoint_list, "view": config.config_checkpoint_view, "restore": config.config_checkpoint_restore, "diff": config.config_checkpoint_diff, }, ["config", "checkpoint"], default_cmd="list" ), "import-cman": config.config_import_cman, "export": create_router( { "pcs-commands": config.config_export_pcs_commands, "pcs-commands-verbose": lambda lib, argv, modifiers: config.config_export_pcs_commands( lib, argv, modifiers, verbose=True ) }, ["config", "export"] ) }, ["config"], default_cmd="show", )
from pcs import ( host, usage, ) from pcs.cli.common.routing import create_router host_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.host(argv), "auth": host.auth_cmd, "deauth": host.deauth_cmd, }, ["host"], )
status_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.status(argv), "booth": booth_status_cmd, "corosync": status.corosync_status, "cluster": status.cluster_status, "nodes": status.nodes_status, "pcsd": status.cluster_pcsd_status, "qdevice": qdevice_status_cmd, "quorum": quorum_status_cmd, "resources": resource_status, "xml": status.xml_status, "status": status.full_status, # removed commands # These print error messages which point users to the changes section in # pcs manpage. # To be removed in the next significant version. "groups": lambda lib, argv, modifiers: raise_command_replaced( "pcs resource group list"), }, ["status"], default_cmd="status", )
qdevice_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.qdevice(argv), "status": qdevice.qdevice_status_cmd, "setup": qdevice.qdevice_setup_cmd, "destroy": qdevice.qdevice_destroy_cmd, "start": qdevice.qdevice_start_cmd, "stop": qdevice.qdevice_stop_cmd, "kill": qdevice.qdevice_kill_cmd, "enable": qdevice.qdevice_enable_cmd, "disable": qdevice.qdevice_disable_cmd, # following commands are internal use only, called from pcsd "sign-net-cert-request": qdevice.qdevice_sign_net_cert_request_cmd, "net-client": create_router( { "setup": qdevice.qdevice_net_client_setup_cmd, "import-certificate": (qdevice.qdevice_net_client_import_certificate_cmd), "destroy": qdevice.qdevice_net_client_destroy, }, ["qdevice", "net-client"], ), }, ["qdevice"], )
resource_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.resource(argv)), "list": resource.resource_list_available, "describe": resource.resource_list_options, "create": resource.resource_create, "move": resource.resource_move, "move-with-constraint": resource.resource_move_with_constraint, "ban": resource.resource_ban, "clear": resource.resource_unmove_unban, "standards": resource.resource_standards, "providers": resource.resource_providers, "agents": resource.resource_agents, "update": resource.resource_update, "meta": resource.resource_meta, "delete": resource.resource_remove_cmd, "remove": resource.resource_remove_cmd, # TODO remove, deprecated command # replaced with 'resource status' and 'resource config' "show": resource.resource_show, "status": resource.resource_status, "config": resource.resource_config, "group": create_router( { "add": resource.resource_group_add_cmd, "list": resource.resource_group_list, "remove": resource.resource_group_rm_cmd, "delete": resource.resource_group_rm_cmd, }, ["resource", "group"], ), "ungroup": resource.resource_group_rm_cmd, "clone": resource.resource_clone, "promotable": partial(resource.resource_clone, promotable=True), "unclone": resource.resource_clone_master_remove, "enable": resource.resource_enable_cmd, "disable": resource.resource_disable_cmd, "safe-disable": resource.resource_safe_disable_cmd, "restart": resource.resource_restart, "debug-start": partial( resource.resource_force_action, action="debug-start" ), "debug-stop": partial( resource.resource_force_action, action="debug-stop" ), "debug-promote": partial( resource.resource_force_action, action="debug-promote" ), "debug-demote": partial( resource.resource_force_action, action="debug-demote" ), "debug-monitor": partial( resource.resource_force_action, action="debug-monitor" ), "manage": resource.resource_manage_cmd, "unmanage": resource.resource_unmanage_cmd, "failcount": create_router( { "show": resource.resource_failcount_show, }, ["resource", "failcount"], default_cmd="show", ), "op": create_router( { "defaults": resource_op_defaults_cmd, "add": resource.resource_op_add_cmd, "remove": resource.resource_op_delete_cmd, "delete": resource.resource_op_delete_cmd, }, ["resource", "op"], ), "defaults": resource_defaults_cmd, "cleanup": resource.resource_cleanup, "refresh": resource.resource_refresh, "relocate": create_router( { "show": resource.resource_relocate_show_cmd, "dry-run": resource.resource_relocate_dry_run_cmd, "run": resource.resource_relocate_run_cmd, "clear": resource.resource_relocate_clear_cmd, }, ["resource", "relocate"], ), "utilization": resource.resource_utilization_cmd, "bundle": create_router( { "create": resource.resource_bundle_create_cmd, "reset": resource.resource_bundle_reset_cmd, "update": resource.resource_bundle_update_cmd, }, ["resource", "bundle"], ), # internal use only "get_resource_agent_info": resource.get_resource_agent_info, "relations": show_resource_relations_cmd, }, ["resource"], default_cmd="status", )
quorum_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.quorum(argv), "config": quorum.quorum_config_cmd, "expected-votes": quorum.quorum_expected_votes_cmd, "status": quorum.quorum_status_cmd, "device": create_router( { "add": quorum.quorum_device_add_cmd, "heuristics": create_router( { "delete": quorum.quorum_device_heuristics_remove_cmd, "remove": quorum.quorum_device_heuristics_remove_cmd, }, ["quorum", "device", "heuristics"]), "delete": quorum.quorum_device_remove_cmd, "remove": quorum.quorum_device_remove_cmd, "status": quorum.quorum_device_status_cmd, "update": quorum.quorum_device_update_cmd, }, ["quorum", "device"]), # TODO switch to new architecture "unblock": quorum.quorum_unblock_cmd, "update": quorum.quorum_update_cmd, }, ["quorum"], default_cmd="config", )
from pcs import client, usage from pcs.cli.common.routing import create_router client_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.client(argv)), "local-auth": client.local_auth_cmd, }, ["client"], )
booth_cmd = create_router( { "help": lambda lib, argv, modifiers: print(usage.booth(argv)), "config": command.config_show, "setup": command.config_setup, "destroy": command.config_destroy, "ticket": create_router( { "help": lambda lib, argv, modifiers: print(usage.booth(["ticket"])), "add": command.config_ticket_add, "delete": command.config_ticket_remove, "remove": command.config_ticket_remove, "grant": command.ticket_grant, "revoke": command.ticket_revoke, }, ["booth", "ticket"], ), "create": command.create_in_cluster, "delete": command.get_remove_from_cluster(resource_remove), "remove": command.get_remove_from_cluster(resource_remove), "restart": command.get_restart(resource_restart), "sync": command.sync, "pull": command.pull, "enable": command.enable, "disable": command.disable, "start": command.start, "stop": command.stop, "status": command.status, }, ["booth"], )
from pcs import ( prop, usage, ) from pcs.cli.common.routing import create_router property_cmd = create_router( { "help": lambda _lib, _argv, _modifiers: usage.property(_argv), "set": prop.set_property, "unset": prop.unset_property, "list": prop.list_property, "show": prop.list_property, "get_cluster_properties_definition": prop.print_cluster_properties_definition, }, ["property"], default_cmd="list")
from functools import partial from pcs import ( node, usage, ) from pcs.cli.common.routing import create_router node_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.node(argv), "maintenance": partial(node.node_maintenance_cmd, enable=True), "unmaintenance": partial(node.node_maintenance_cmd, enable=False), "standby": partial(node.node_standby_cmd, enable=True), "unstandby": partial(node.node_standby_cmd, enable=False), "attribute": node.node_attribute_cmd, "utilization": node.node_utilization_cmd, # pcs-to-pcsd use only "pacemaker-status": node.node_pacemaker_status, }, ["node"])
from pcs import ( host, usage, ) from pcs.cli.common.routing import create_router host_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.host(argv), "auth": host.auth_cmd, "deauth": host.deauth_cmd, }, ["host"] )
from functools import partial from pcs import ( node, usage, ) from pcs.cli.common.routing import create_router node_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.node(argv), "maintenance": partial(node.node_maintenance_cmd, enable=True), "unmaintenance": partial(node.node_maintenance_cmd, enable=False), "standby": partial(node.node_standby_cmd, enable=True), "unstandby": partial(node.node_standby_cmd, enable=False), "attribute": node.node_attribute_cmd, "utilization": node.node_utilization_cmd, # pcs-to-pcsd use only "pacemaker-status": node.node_pacemaker_status, }, ["node"] )
booth_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.booth(argv), "config": command.config_show, "setup": command.config_setup, "destroy": command.config_destroy, "ticket": create_router( { "help": lambda lib, argv, modifiers: usage.booth(["ticket"]), "add": command.config_ticket_add, "delete": command.config_ticket_remove, "remove": command.config_ticket_remove, "grant": command.ticket_grant, "revoke": command.ticket_revoke, }, ["booth", "ticket"] ), "create": command.create_in_cluster, "delete": command.get_remove_from_cluster(resource_remove), "remove": command.get_remove_from_cluster(resource_remove), "restart": command.get_restart(resource_restart), "sync": command.sync, "pull": command.pull, "enable": command.enable, "disable": command.disable, "start": command.start, "stop": command.stop, "status": command.status, }, ["booth"] )
from pcs import ( pcsd, usage, ) from pcs.cli.common.errors import raise_command_replaced from pcs.cli.common.routing import create_router pcsd_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.pcsd(argv), "accept_token": pcsd.accept_token_cmd, "deauth": pcsd.pcsd_deauth, "certkey": pcsd.pcsd_certkey, "sync-certificates": pcsd.pcsd_sync_certs, # removed commands # These print error messages which point users to the changes section in # pcs manpage. # To be removed in the next significant version. "clear-auth": lambda lib, argv, modifiers: raise_command_replaced( "pcs host deauth", "pcs pcsd deauth"), }, ["pcsd"], )
quorum_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.quorum(argv), "config": quorum.quorum_config_cmd, "expected-votes": quorum.quorum_expected_votes_cmd, "status": quorum.quorum_status_cmd, "device": create_router( { "add": quorum.quorum_device_add_cmd, "heuristics": create_router( { "delete": quorum.quorum_device_heuristics_remove_cmd, "remove": quorum.quorum_device_heuristics_remove_cmd, }, ["quorum", "device", "heuristics"] ), "delete": quorum.quorum_device_remove_cmd, "remove": quorum.quorum_device_remove_cmd, "status": quorum.quorum_device_status_cmd, "update": quorum.quorum_device_update_cmd, }, ["quorum", "device"] ), # TODO switch to new architecture "unblock": quorum.quorum_unblock_cmd, "update": quorum.quorum_update_cmd, }, ["quorum"], default_cmd="config", )
cluster_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.cluster(argv), "setup": cluster.cluster_setup, "sync": create_router( { "corosync": cluster.sync_nodes, }, ["cluster", "sync"], default_cmd="corosync", ), "status": status.cluster_status, "pcsd-status": status.cluster_pcsd_status, "certkey": pcsd.pcsd_certkey, "auth": cluster.cluster_auth_cmd, "start": cluster.cluster_start_cmd, "stop": cluster.cluster_stop_cmd, "kill": cluster.kill_cluster, "enable": cluster.cluster_enable_cmd, "disable": cluster.cluster_disable_cmd, "cib": cluster.get_cib, "cib-push": cluster.cluster_push, "cib-upgrade": cluster.cluster_cib_upgrade_cmd, "edit": cluster.cluster_edit, "link": create_router( { "add": cluster.link_add, "delete": cluster.link_remove, "remove": cluster.link_remove, "update": cluster.link_update, }, ["cluster", "link"] ), "node": create_router( { "add": cluster.node_add, "add-guest": cluster_command.node_add_guest, "add-outside": cluster.node_add_outside_cluster, "add-remote": cluster_command.node_add_remote, "clear": cluster_command.node_clear, "delete": cluster.node_remove, "delete-guest": cluster_command.node_remove_guest, "delete-remote": cluster_command.create_node_remove_remote( resource.resource_remove ), "remove": cluster.node_remove, "remove-guest": cluster_command.node_remove_guest, "remove-remote": cluster_command.create_node_remove_remote( resource.resource_remove ), }, ["cluster", "node"] ), "uidgid": cluster.cluster_uidgid, "corosync": cluster.cluster_get_corosync_conf, "reload": cluster.cluster_reload, "destroy": cluster.cluster_destroy, "verify": cluster.cluster_verify, "report": cluster.cluster_report, "remove_nodes_from_cib": cluster.remove_nodes_from_cib, }, ["cluster"] )
resource_cmd = create_router( { "help": lambda lib, argv, modifiers: usage.resource(argv), "list": resource.resource_list_available, "describe": resource.resource_list_options, "create": resource.resource_create, "move": resource.resource_move, "ban": resource.resource_ban, "clear": resource.resource_unmove_unban, "standards": resource.resource_standards, "providers": resource.resource_providers, "agents": resource.resource_agents, "update": resource.resource_update, "meta": resource.resource_meta, "delete": resource.resource_remove_cmd, "remove": resource.resource_remove_cmd, # TODO remove, deprecated command # replaced with 'resource status' and 'resource config' "show": resource.resource_show, "status": resource.resource_status, "config": resource.resource_config, "group": create_router( { "add": resource.resource_group_add_cmd, "list": resource.resource_group_list, "remove": resource.resource_group_rm_cmd, "delete": resource.resource_group_rm_cmd, }, ["resource", "group"], ), "ungroup": resource.resource_group_rm_cmd, "clone": resource.resource_clone, "promotable": partial(resource.resource_clone, promotable=True), "unclone": resource.resource_clone_master_remove, "enable": resource.resource_enable_cmd, "disable": resource.resource_disable_cmd, "restart": resource.resource_restart, "debug-start": partial( resource.resource_force_action, action="debug-start" ), "debug-stop": partial( resource.resource_force_action, action="debug-stop" ), "debug-promote": partial( resource.resource_force_action, action="debug-promote" ), "debug-demote": partial( resource.resource_force_action, action="debug-demote" ), "debug-monitor": partial( resource.resource_force_action, action="debug-monitor" ), "manage": resource.resource_manage_cmd, "unmanage": resource.resource_unmanage_cmd, "failcount": resource.resource_failcount, "op": create_router( { "defaults": resource.resource_op_defaults_cmd, "add": resource.resource_op_add_cmd, "remove": resource.resource_op_delete_cmd, "delete": resource.resource_op_delete_cmd, }, ["resource", "op"] ), "defaults": resource.resource_defaults_cmd, "cleanup": resource.resource_cleanup, "refresh": resource.resource_refresh, "relocate": create_router( { "show": resource.resource_relocate_show_cmd, "dry-run": resource.resource_relocate_dry_run_cmd, "run": resource.resource_relocate_run_cmd, "clear": resource.resource_relocate_clear_cmd, }, ["resource", "relocate"] ), "utilization": resource.resource_utilization_cmd, "bundle": create_router( { "create": resource.resource_bundle_create_cmd, "reset": resource.resource_bundle_reset_cmd, "update": resource.resource_bundle_update_cmd, }, ["resource", "bundle"] ), # internal use only "get_resource_agent_info": resource.get_resource_agent_info }, ["resource"], default_cmd="status" )