Revision 801bccba lib/client/gnt_group.py
b/lib/client/gnt_group.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010, 2011, 2012 Google Inc. |
|
4 |
# Copyright (C) 2010, 2011, 2012, 2013 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
29 | 29 |
from ganeti import opcodes |
30 | 30 |
from ganeti import utils |
31 | 31 |
from ganeti import compat |
32 |
from cStringIO import StringIO |
|
33 | 32 |
|
34 | 33 |
|
35 | 34 |
#: default list of fields for L{ListGroups} |
... | ... | |
283 | 282 |
return rcode |
284 | 283 |
|
285 | 284 |
|
286 |
def _FormatDict(custom, actual, level=2): |
|
287 |
"""Helper function to L{cli.FormatParameterDict}. |
|
288 |
|
|
289 |
@param custom: The customized dict |
|
290 |
@param actual: The fully filled dict |
|
291 |
|
|
292 |
""" |
|
293 |
buf = StringIO() |
|
294 |
FormatParameterDict(buf, custom, actual, level=level) |
|
295 |
return buf.getvalue().rstrip("\n") |
|
285 |
def _FormatGroupInfo(group): |
|
286 |
(name, ndparams, custom_ndparams, diskparams, custom_diskparams, |
|
287 |
ipolicy, custom_ipolicy) = group |
|
288 |
return [ |
|
289 |
("Node group", name), |
|
290 |
("Node parameters", FormatParamsDictInfo(custom_ndparams, ndparams)), |
|
291 |
("Disk parameters", FormatParamsDictInfo(custom_diskparams, diskparams)), |
|
292 |
("Instance policy", FormatPolicyInfo(custom_ipolicy, ipolicy, False)), |
|
293 |
] |
|
296 | 294 |
|
297 | 295 |
|
298 | 296 |
def GroupInfo(_, args): |
... | ... | |
307 | 305 |
result = cl.QueryGroups(names=args, fields=selected_fields, |
308 | 306 |
use_locking=False) |
309 | 307 |
|
310 |
for (name, |
|
311 |
ndparams, custom_ndparams, |
|
312 |
diskparams, custom_diskparams, |
|
313 |
ipolicy, custom_ipolicy) in result: |
|
314 |
ToStdout("Node group: %s" % name) |
|
315 |
ToStdout(" Node parameters:") |
|
316 |
ToStdout(_FormatDict(custom_ndparams, ndparams)) |
|
317 |
ToStdout(" Disk parameters:") |
|
318 |
ToStdout(_FormatDict(custom_diskparams, diskparams)) |
|
319 |
ToStdout(" Instance policy:") |
|
320 |
ToStdout(_FormatDict(custom_ipolicy, ipolicy)) |
|
308 |
PrintGenericInfo([ |
|
309 |
_FormatGroupInfo(group) for group in result |
|
310 |
]) |
|
321 | 311 |
|
322 | 312 |
|
323 | 313 |
commands = { |
Also available in: Unified diff