Skip to content

Commit

Permalink
Dev: Improve options of 'crm status' command
Browse files Browse the repository at this point in the history
- Reduce duplicated options definition
- Drop deprecated '-s/--simple-status' option
  • Loading branch information
liangxin1300 committed Jan 19, 2025
1 parent f23740a commit 7548d9b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
35 changes: 17 additions & 18 deletions crmsh/cmd_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions crmsh/completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion crmsh/ui_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7548d9b

Please sign in to comment.