Expose new node group attributes in CLI and RAPI
authorAdeodato Simo <dato@google.com>
Thu, 2 Dec 2010 16:56:36 +0000 (16:56 +0000)
committerAdeodato Simo <dato@google.com>
Wed, 8 Dec 2010 12:27:18 +0000 (12:27 +0000)
Signed-off-by: Adeodato Simo <dato@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/client/gnt_group.py
lib/cmdlib.py
lib/rapi/rlib2.py
man/gnt-group.rst

index 2bdc193..5477b11 100644 (file)
@@ -26,6 +26,7 @@
 
 from ganeti.cli import *
 from ganeti import compat
+from ganeti import utils
 
 
 #: default list of fields for L{ListGroups}
@@ -37,6 +38,7 @@ _LIST_HEADERS = {
   "name": "Group", "uuid": "UUID",
   "node_cnt": "Nodes", "node_list": "NodeList",
   "pinst_cnt": "Instances", "pinst_list": "InstanceList",
+  "ctime": "CTime", "mtime": "MTime", "serial_no": "SerialNo",
 }
 
 
@@ -59,8 +61,9 @@ def ListGroups(opts, args):
   else:
     headers = _LIST_HEADERS
 
-  int_type_fields = frozenset(["node_cnt", "pinst_cnt"])
+  int_type_fields = frozenset(["node_cnt", "pinst_cnt", "serial_no"])
   list_type_fields = frozenset(["node_list", "pinst_list"])
+  date_type_fields = frozenset(["mtime", "ctime"])
 
   for row in output:
     for idx, field in enumerate(desired_fields):
@@ -70,6 +73,8 @@ def ListGroups(opts, args):
         val = ",".join(val)
       elif opts.roman_integers and field in int_type_fields:
         val = compat.TryToRoman(val)
+      elif field in date_type_fields:
+        val = utils.FormatTime(val)
       elif val is None:
         val = "?"
 
@@ -88,7 +93,10 @@ commands = {
   "list": (
     ListGroups, ARGS_MANY_GROUPS,
     [NOHDR_OPT, SEP_OPT, FIELDS_OPT, SYNC_OPT, ROMAN_OPT],
-    "[<group_name>...]", "Lists the node groups in the cluster."),
+    "[<group_name>...]",
+    "Lists the node groups in the cluster. The available fields are (see"
+    " the man page for details): %s. The default list is (in order): %s." %
+    (utils.CommaJoin(_LIST_HEADERS), utils.CommaJoin(_LIST_DEF_FIELDS))),
 }
 
 
index 97316a2..9505e19 100644 (file)
@@ -10311,7 +10311,7 @@ class LUQueryGroups(NoHooksLU):
 
   _FIELDS_DYNAMIC = utils.FieldSet()
 
-  _SIMPLE_FIELDS = ["name", "uuid"]
+  _SIMPLE_FIELDS = ["name", "uuid", "ctime", "mtime", "serial_no"]
 
   _FIELDS_STATIC = utils.FieldSet(
       "node_cnt", "node_list", "pinst_cnt", "pinst_list", *_SIMPLE_FIELDS)
index 8f5dc38..39514a0 100644 (file)
@@ -75,7 +75,8 @@ N_FIELDS = ["name", "offline", "master_candidate", "drained",
 
 G_FIELDS = ["name", "uuid",
             "node_cnt", "node_list",
-            ]
+            "ctime", "mtime", "serial_no",
+            ]  # "tags" is missing to be able to use _COMMON_FIELDS here.
 
 _NR_DRAINED = "drained"
 _NR_MASTER_CANDIATE = "master-candidate"
index 6c8641b..086d648 100644 (file)
@@ -60,5 +60,21 @@ pinst_cnt
 pinst_list
     the list of primary instances in the group
 
+ctime
+    the creation time of the group; note that this field contains spaces
+    and as such it's harder to parse
+
+    if this attribute is not present (e.g. when upgrading from older
+    versions), then "N/A" will be shown instead
+
+mtime
+    the last modification time of the group; note that this field
+    contains spaces and as such it's harder to parse
+
+serial_no
+    the so called 'serial number' of the group; this is a numeric field
+    that is incremented each time the node is modified, and it can be
+    used to detect modifications
+
 If no group names are given, then all groups are included. Otherwise,
 only the named groups will be listed.