From 7548d9bea11eefca8cc9555d5de87b0651d1a5ac Mon Sep 17 00:00:00 2001 From: xin liang Date: Sun, 19 Jan 2025 19:04:34 +0800 Subject: [PATCH] Dev: Improve options of 'crm status' command - Reduce duplicated options definition - Drop deprecated '-s/--simple-status' option --- crmsh/cmd_status.py | 35 +++++++++++++++++------------------ crmsh/completers.py | 4 ---- crmsh/ui_root.py | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/crmsh/cmd_status.py b/crmsh/cmd_status.py index 541cadc49c..c1907b1331 100644 --- a/crmsh/cmd_status.py +++ b/crmsh/cmd_status.py @@ -41,6 +41,22 @@ 'Unknown', 'OFFLINE', 'Failed actions'] +CRM_MON_OPTIONS_MAP = { + "bynode": "-n", + "inactive": "-r", + "ops": "-o", + "timing": "-t", + "failcounts": "-f", + "verbose": "-V", + "quiet": "-Q", + "html": "--output-as html", + "xml": "--output-as xml", + "tickets": "-c", + "noheaders": "-D", + "detail": "-R", + "brief": "-b", + "full": "-ncrft", +} class CrmMonFilter(object): @@ -96,24 +112,7 @@ def cmd_status(args): Displays the output, paging if necessary. Raises IOError if crm_mon fails. ''' - opts = { - "bynode": "-n", - "inactive": "-r", - "ops": "-o", - "timing": "-t", - "failcounts": "-f", - "verbose": "-V", - "quiet": "-Q", - "html": "--output-as html", - "xml": "--output-as xml", - "simple": "-s", - "tickets": "-c", - "noheaders": "-D", - "detail": "-R", - "brief": "-b", - "full": "-ncrft", - } - extra = ' '.join(opts.get(arg, arg) for arg in args) + extra = ' '.join(CRM_MON_OPTIONS_MAP.get(arg, arg) for arg in args) if not args: extra = "-r" rc, s, err = crm_mon(extra) diff --git a/crmsh/completers.py b/crmsh/completers.py index a7b98833af..ad395ed749 100644 --- a/crmsh/completers.py +++ b/crmsh/completers.py @@ -74,7 +74,3 @@ def primitives(args): standby_nodes = call(lambda x: xmlutil.CrmMonXmlParser().get_node_list(x), "standby") shadows = call(xmlutil.listshadows) - -status_option = """full bynode inactive ops timing failcounts - verbose quiet xml simple tickets noheaders - detail brief""".split() diff --git a/crmsh/ui_root.py b/crmsh/ui_root.py index 7e35586b89..feef2b8652 100644 --- a/crmsh/ui_root.py +++ b/crmsh/ui_root.py @@ -173,7 +173,7 @@ def do_script(self): def do_site(self): pass - @command.completers(compl.choice(compl.status_option)) + @command.completers(compl.choice(cmd_status.CRM_MON_OPTIONS_MAP)) @command.help('''show cluster status Show cluster status. The status is displayed by `crm_mon`. Supply additional arguments for more information or different format.