From d8a4b51dfd842f8954398a8381f0faf92d5d5cf1 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 28 Jan 2008 14:32:47 +0000
Subject: [PATCH] Improve the documentation of query output fields
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The gnt-node and gnt-instance list commands have a customizable list of
output fields, but the list is not up to date (in the man page) and not
easily understandable from the β€˜--help’ output.

This patch updates the man pages and adds the available fields and
default fields in the β€˜--help’ output, as part of the description.

Example:
Usage
=====
  gnt-node list

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. The default field list is (in
order): name, dtotal, dfree, mtotal, mnode, mfree, pinst_cnt, sinst_cnt.

Reviewed-by: imsnah,ultrotter
---
 lib/cli.py            |  3 ++-
 man/gnt-instance.sgml | 19 +++++++++++++++++++
 man/gnt-node.sgml     | 27 +++++++++++++++++++++++++--
 scripts/gnt-instance  |  7 ++++++-
 scripts/gnt-node      |  6 +++++-
 5 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index d2bcf6f4e..a58f5505b 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -167,7 +167,8 @@ USEUNITS_OPT = make_option("--human-readable", default=False,
                            help="Print sizes in human readable format")
 
 FIELDS_OPT = make_option("-o", "--output", dest="output", action="store",
-                         type="string", help="Select output fields",
+                         type="string", help="Comma separated list of"
+                         " output fields",
                          metavar="FIELDS")
 
 FORCE_OPT = make_option("-f", "--force", dest="force", action="store_true",
diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml
index 36a6c1468..100d85687 100644
--- a/man/gnt-instance.sgml
+++ b/man/gnt-instance.sgml
@@ -436,6 +436,25 @@
                 </simpara>
               </listitem>
             </varlistentry>
+            <varlistentry>
+              <term>sda_size</term>
+              <listitem>
+                <simpara>the size of the instance's first disk</simpara>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>sdb_size</term>
+              <listitem>
+                <simpara>the size of the instance's second disk</simpara>
+              </listitem>
+            </varlistentry>
+            <varlistentry>
+              <term>vcpus</term>
+              <listitem>
+                <simpara>the number of VCPUs allocated to the
+                instance</simpara>
+              </listitem>
+            </varlistentry>
           </variablelist>
         </para>
 
diff --git a/man/gnt-node.sgml b/man/gnt-node.sgml
index d44847b8c..f6d4c3e2d 100644
--- a/man/gnt-node.sgml
+++ b/man/gnt-node.sgml
@@ -232,19 +232,33 @@
             </listitem>
           </varlistentry>
           <varlistentry>
-            <term>pinst</term>
+            <term>pinst_cnt</term>
             <listitem>
               <simpara>the number of instances having this node as
               primary</simpara>
             </listitem>
           </varlistentry>
           <varlistentry>
-            <term>sinst</term>
+            <term>pinst_list</term>
+            <listitem>
+              <simpara>the list of instances having this node as
+              primary, comma separated</simpara>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
+            <term>sinst_cnt</term>
             <listitem>
               <simpara>the number of instances having this node as a
               secondary node</simpara>
             </listitem>
           </varlistentry>
+          <varlistentry>
+            <term>sinst_list</term>
+            <listitem>
+              <simpara>the list of instances having this node as a
+              secondary node, comma separated</simpara>
+            </listitem>
+          </varlistentry>
           <varlistentry>
             <term>pip</term>
             <listitem>
@@ -296,6 +310,15 @@
               allocations</simpara>
             </listitem>
           </varlistentry>
+          <varlistentry>
+            <term>bootid</term>
+            <listitem>
+              <simpara>the node bootid value; this is a linux specific
+              feature that assigns a new UUID to the node at each boot
+              and can be use to detect node reboots (by tracking
+              changes in this value)</simpara>
+            </listitem>
+          </varlistentry>
         </variablelist>
       </para>
 
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index fd54f7ce7..5842b39c4 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -811,7 +811,12 @@ commands = {
            "Show information on the specified instance"),
   'list': (ListInstances, ARGS_NONE,
            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
-           "", "Lists the instances and their status"),
+           "", "Lists the instances and their status. The available fields"
+           " are (see the man page for details): oper_state, oper_ram,"
+           " name, os, pnode, snodes, admin_state, admin_ram, disk_template,"
+           " ip, mac, bridge, sda_size, sdb_size, vcpus. The default field"
+           " list is (in order): name, os, pnode, admin_state, oper_state,"
+           " oper_ram."),
   'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
                 "[-f] <instance>", "Reinstall the instance"),
   'remove': (RemoveInstance, ARGS_ONE,
diff --git a/scripts/gnt-node b/scripts/gnt-node
index 8078af792..df37be6a3 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -300,7 +300,11 @@ commands = {
            "[<node_name>...]", "Show information about the node(s)"),
   'list': (ListNodes, ARGS_NONE,
            [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
-           "", "Lists the nodes in the cluster"),
+           "", "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. The default field list is (in order): name,"
+           " dtotal, dfree, mtotal, mnode, mfree, pinst_cnt, sinst_cnt."),
   'remove': (RemoveNode, ARGS_ONE, [DEBUG_OPT],
              "<node_name>", "Removes a node from the cluster"),
   'volumes': (ListVolumes, ARGS_ANY,
-- 
GitLab