From cc3bcec8c721165bb7c308644054c7eb9eb11220 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 3 Dec 2008 10:28:50 +0000 Subject: [PATCH] Extract the ListNodes headers and use them in help Currently we have to update both the ListNodes headers and the online help for the full field list. This patch uses the headers keys for the help, thus removing duplicating places to update, and adding hope that we'll have things in sync. As a downside we lose ordering of the non-default fields in the online help. Reviewed-by: imsnah --- scripts/gnt-node | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/gnt-node b/scripts/gnt-node index 6e2d686b2..d22d17e92 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -41,6 +41,21 @@ _LIST_DEF_FIELDS = [ "pinst_cnt", "sinst_cnt", ] +#: headers (and full field list for L{ListNodes} +_LIST_HEADERS = { + "name": "Node", "pinst_cnt": "Pinst", "sinst_cnt": "Sinst", + "pinst_list": "PriInstances", "sinst_list": "SecInstances", + "pip": "PrimaryIP", "sip": "SecondaryIP", + "dtotal": "DTotal", "dfree": "DFree", + "mtotal": "MTotal", "mnode": "MNode", "mfree": "MFree", + "bootid": "BootID", + "ctotal": "CTotal", + "tags": "Tags", + "serial_no": "SerialNo", + "master_candidate": "MasterC", + "master": "IsMaster", + } + @UsesRPC def AddNode(opts, args): @@ -105,19 +120,7 @@ def ListNodes(opts, args): output = GetClient().QueryNodes([], selected_fields) if not opts.no_headers: - headers = { - "name": "Node", "pinst_cnt": "Pinst", "sinst_cnt": "Sinst", - "pinst_list": "PriInstances", "sinst_list": "SecInstances", - "pip": "PrimaryIP", "sip": "SecondaryIP", - "dtotal": "DTotal", "dfree": "DFree", - "mtotal": "MTotal", "mnode": "MNode", "mfree": "MFree", - "bootid": "BootID", - "ctotal": "CTotal", - "tags": "Tags", - "serial_no": "SerialNo", - "master_candidate": "MasterC", - "master": "IsMaster", - } + headers = _LIST_HEADERS else: headers = None @@ -431,12 +434,9 @@ commands = { [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SUBMIT_OPT], "", "Lists the nodes in the cluster. The available fields" - " are (see the man page for details): name, pinst_cnt, pinst_list," - " sinst_cnt, sinst_list, pip, sip, dtotal, dfree, mtotal, mnode," - " mfree, bootid, cpu_count, serial_no." - " The default field list is" - " (in order): %s." % ", ".join(_LIST_DEF_FIELDS), - ), + " are (see the man page for details): %s" + " The default field list is (in order): %s." % + (", ".join(_LIST_HEADERS), ", ".join(_LIST_DEF_FIELDS))), 'modify': (SetNodeParams, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, SUBMIT_OPT, -- GitLab