Skip to content
Snippets Groups Projects
Commit 801bccba authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

gnt-group info uses a revised format


The code is more modular, the output is more similar to "gnt-cluster info"
and is YAML-compliant.

Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent d00884a2
No related branches found
No related tags found
No related merge requests found
# #
# #
# Copyright (C) 2010, 2011, 2012 Google Inc. # Copyright (C) 2010, 2011, 2012, 2013 Google Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -29,7 +29,6 @@ from ganeti import constants ...@@ -29,7 +29,6 @@ from ganeti import constants
from ganeti import opcodes from ganeti import opcodes
from ganeti import utils from ganeti import utils
from ganeti import compat from ganeti import compat
from cStringIO import StringIO
#: default list of fields for L{ListGroups} #: default list of fields for L{ListGroups}
...@@ -283,16 +282,15 @@ def EvacuateGroup(opts, args): ...@@ -283,16 +282,15 @@ def EvacuateGroup(opts, args):
return rcode return rcode
def _FormatDict(custom, actual, level=2): def _FormatGroupInfo(group):
"""Helper function to L{cli.FormatParameterDict}. (name, ndparams, custom_ndparams, diskparams, custom_diskparams,
ipolicy, custom_ipolicy) = group
@param custom: The customized dict return [
@param actual: The fully filled dict ("Node group", name),
("Node parameters", FormatParamsDictInfo(custom_ndparams, ndparams)),
""" ("Disk parameters", FormatParamsDictInfo(custom_diskparams, diskparams)),
buf = StringIO() ("Instance policy", FormatPolicyInfo(custom_ipolicy, ipolicy, False)),
FormatParameterDict(buf, custom, actual, level=level) ]
return buf.getvalue().rstrip("\n")
def GroupInfo(_, args): def GroupInfo(_, args):
...@@ -307,17 +305,9 @@ def GroupInfo(_, args): ...@@ -307,17 +305,9 @@ def GroupInfo(_, args):
result = cl.QueryGroups(names=args, fields=selected_fields, result = cl.QueryGroups(names=args, fields=selected_fields,
use_locking=False) use_locking=False)
for (name, PrintGenericInfo([
ndparams, custom_ndparams, _FormatGroupInfo(group) for group in result
diskparams, custom_diskparams, ])
ipolicy, custom_ipolicy) in result:
ToStdout("Node group: %s" % name)
ToStdout(" Node parameters:")
ToStdout(_FormatDict(custom_ndparams, ndparams))
ToStdout(" Disk parameters:")
ToStdout(_FormatDict(custom_diskparams, diskparams))
ToStdout(" Instance policy:")
ToStdout(_FormatDict(custom_ipolicy, ipolicy))
commands = { commands = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment