Add group, group.uuid fields in node list
authorIustin Pop <iustin@google.com>
Thu, 11 Nov 2010 10:50:23 +0000 (11:50 +0100)
committerIustin Pop <iustin@google.com>
Thu, 11 Nov 2010 12:18:05 +0000 (13:18 +0100)
This is needed to at least see the current group configuration.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/client/gnt_node.py
lib/cmdlib.py
man/gnt-node.sgml

index 71d48ba..a73ed7c 100644 (file)
@@ -77,6 +77,7 @@ _LIST_HEADERS = {
   "role": "Role",
   "ctime": "CTime", "mtime": "MTime", "uuid": "UUID",
   "master_capable": "MasterCapable", "vm_capable": "VMCapable",
+  "group": "Group", "group.uuid": "GroupUUID",
   }
 
 
index c2085b9..babc361 100644 (file)
@@ -3361,8 +3361,9 @@ class LUQueryNodes(NoHooksLU):
     "pinst_cnt", "sinst_cnt",
     "pinst_list", "sinst_list",
     "pip", "sip", "tags",
-    "master",
-    "role"] + _SIMPLE_FIELDS
+    "master", "role",
+    "group.uuid", "group",
+    ] + _SIMPLE_FIELDS
     )
 
   def CheckArguments(self):
@@ -3404,6 +3405,11 @@ class LUQueryNodes(NoHooksLU):
     nodenames = utils.NiceSort(nodenames)
     nodelist = [all_info[name] for name in nodenames]
 
+    if "group" in self.op.output_fields:
+      groups = self.cfg.GetAllNodeGroupsInfo()
+    else:
+      groups = {}
+
     # begin data gathering
 
     if self.do_node_query:
@@ -3485,6 +3491,14 @@ class LUQueryNodes(NoHooksLU):
             val = "O"
           else:
             val = "R"
+        elif field == "group.uuid":
+          val = node.group
+        elif field == "group":
+          ng = groups.get(node.group, None)
+          if ng is None:
+            val = "<unknown>"
+          else:
+            val = ng.name
         else:
           raise errors.ParameterError(field)
         node_output.append(val)
index 2294701..a2eca13 100644 (file)
               <para>whether the node can host instances</para>
             </listitem>
           </varlistentry>
+          <varlistentry>
+            <term>group</term>
+            <listitem>
+              <para>the name of the node's group, if known (the query
+              is done without locking, so data consistency is not
+              guaranteed)</para>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
+            <term>group.uuid</term>
+            <listitem>
+              <para>the UUID of the node's group</para>
+            </listitem>
+          </varlistentry>
         </variablelist>
       </para>