From b288b6f32a169d776bd4fbe1fe4dbee3007d60db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Wed, 12 Jan 2011 10:50:17 +0100
Subject: [PATCH] List node parameters in gnt-group list
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: RenΓ© Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>
---
 lib/client/gnt_group.py | 22 ++++++++++++++++++++--
 lib/query.py            |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
index 9b14c25bb..063928f9b 100644
--- a/lib/client/gnt_group.py
+++ b/lib/client/gnt_group.py
@@ -31,7 +31,7 @@ from ganeti import utils
 
 
 #: default list of fields for L{ListGroups}
-_LIST_DEF_FIELDS = ["name", "node_cnt", "pinst_cnt", "alloc_policy"]
+_LIST_DEF_FIELDS = ["name", "node_cnt", "pinst_cnt", "alloc_policy", "ndparams"]
 
 
 def AddGroup(opts, args):
@@ -68,6 +68,20 @@ def AssignNodes(opts, args):
   SubmitOpCode(op, opts=opts)
 
 
+def _FmtDict(data):
+  """Format dict data into command-line format.
+
+  @param data: The input dict to be formatted
+  @return: The formatted dict
+
+  """
+  if not data:
+    return "(empty)"
+
+  return utils.CommaJoin(["%s=%s" % (key, value)
+                          for key, value in data.items()])
+
+
 def ListGroups(opts, args):
   """List node groups and their properties.
 
@@ -79,7 +93,11 @@ def ListGroups(opts, args):
 
   """
   desired_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
-  fmtoverride = dict.fromkeys(["node_list", "pinst_list"], (",".join, False))
+  fmtoverride = {
+    "node_list": (",".join, False),
+    "pinst_list": (",".join, False),
+    "ndparams": (_FmtDict, False),
+    }
 
   return GenericList(constants.QR_GROUP, desired_fields, args, None,
                      opts.separator, not opts.no_headers,
diff --git a/lib/query.py b/lib/query.py
index 25263ce41..21caea6ae 100644
--- a/lib/query.py
+++ b/lib/query.py
@@ -1157,6 +1157,7 @@ _GROUP_SIMPLE_FIELDS = {
   "name": ("Group", constants.QFT_TEXT),
   "serial_no": ("SerialNo", constants.QFT_NUMBER),
   "uuid": ("UUID", constants.QFT_TEXT),
+  "ndparams": ("NDParams", constants.QFT_OTHER),
   }
 
 
-- 
GitLab