def stonith_cmd(argv): if len(argv) < 1: sub_cmd, argv_next = "show", [] else: sub_cmd, argv_next = argv[0], argv[1:] lib = utils.get_library_wrapper() modifiers = utils.get_modifiers() try: if sub_cmd == "help": usage.stonith([" ".join(argv_next)] if argv_next else []) elif sub_cmd == "list": stonith_list_available(lib, argv_next, modifiers) elif sub_cmd == "describe": stonith_list_options(lib, argv_next, modifiers) elif sub_cmd == "create": stonith_create(lib, argv_next, modifiers) elif sub_cmd == "update": if len(argv_next) > 1: stn_id = argv_next.pop(0) resource.resource_update(stn_id, argv_next) else: raise CmdLineInputError() elif sub_cmd == "delete": if len(argv_next) == 1: stn_id = argv_next.pop(0) resource.resource_remove(stn_id) else: raise CmdLineInputError() elif sub_cmd == "show": resource.resource_show(argv_next, True) levels = stonith_level_config_to_str( lib.fencing_topology.get_config()) if levels: print("\n".join(indent(levels, 1))) elif sub_cmd == "level": stonith_level_cmd(lib, argv_next, modifiers) elif sub_cmd == "fence": stonith_fence(argv_next) elif sub_cmd == "cleanup": resource.resource_cleanup(argv_next) elif sub_cmd == "refresh": resource.resource_refresh(argv_next) elif sub_cmd == "confirm": stonith_confirm(argv_next) elif sub_cmd == "get_fence_agent_info": get_fence_agent_info(argv_next) elif sub_cmd == "sbd": sbd_cmd(lib, argv_next, modifiers) elif sub_cmd == "enable": resource.resource_enable_cmd(lib, argv_next, modifiers) elif sub_cmd == "disable": resource.resource_disable_cmd(lib, argv_next, 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, "stonith", sub_cmd)
def stonith_cmd(lib, argv, modifiers): if argv: sub_cmd, argv_next = argv[0], argv[1:] else: sub_cmd, argv_next = "status", [] try: if sub_cmd == "help": usage.stonith([" ".join(argv_next)] if argv_next else []) elif sub_cmd == "list": stonith_list_available(lib, argv_next, modifiers) elif sub_cmd == "describe": stonith_list_options(lib, argv_next, modifiers) elif sub_cmd == "create": stonith_create(lib, argv_next, modifiers) elif sub_cmd == "update": resource.resource_update(lib, argv_next, modifiers) elif sub_cmd in {"delete", "remove"}: resource.resource_remove_cmd(lib, argv_next, modifiers) # TODO remove, deprecated command # replaced with 'stonith status' and 'stonith config' elif sub_cmd == "show": resource.resource_show(lib, argv_next, modifiers, stonith=True) print_stonith_levels(lib) elif sub_cmd == "status": resource.resource_status(lib, argv_next, modifiers, stonith=True) print_stonith_levels(lib) elif sub_cmd == "config": resource.resource_config(lib, argv_next, modifiers, stonith=True) print_stonith_levels(lib) elif sub_cmd == "level": stonith_level_cmd(lib, argv_next, modifiers) elif sub_cmd == "fence": stonith_fence(lib, argv_next, modifiers) elif sub_cmd == "cleanup": resource.resource_cleanup(lib, argv_next, modifiers) elif sub_cmd == "refresh": resource.resource_refresh(lib, argv_next, modifiers) elif sub_cmd == "confirm": stonith_confirm(lib, argv_next, modifiers) elif sub_cmd == "get_fence_agent_info": get_fence_agent_info(lib, argv_next, modifiers) elif sub_cmd == "sbd": sbd_cmd(lib, argv_next, modifiers) elif sub_cmd == "enable": resource.resource_enable_cmd(lib, argv_next, modifiers) elif sub_cmd == "disable": resource.resource_disable_cmd(lib, argv_next, modifiers) elif sub_cmd == "history": stonith_history_cmd(lib, argv_next, 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, "stonith", sub_cmd)