29 |
29 |
from ganeti import objects
|
30 |
30 |
from ganeti import opcodes
|
31 |
31 |
from ganeti import utils
|
|
32 |
from cStringIO import StringIO
|
32 |
33 |
|
33 |
34 |
|
34 |
35 |
#: default list of fields for L{ListGroups}
|
... | ... | |
273 |
274 |
|
274 |
275 |
return rcode
|
275 |
276 |
|
|
277 |
|
|
278 |
def _FormatDict(custom, actual, level=2):
|
|
279 |
"""Helper function to L{cli.FormatParameterDict}.
|
|
280 |
|
|
281 |
@param custom: The customized dict
|
|
282 |
@param actual: The fully filled dict
|
|
283 |
|
|
284 |
"""
|
|
285 |
buf = StringIO()
|
|
286 |
FormatParameterDict(buf, custom, actual, level=level)
|
|
287 |
return buf.getvalue().rstrip("\n")
|
|
288 |
|
|
289 |
|
|
290 |
def GroupInfo(_, args):
|
|
291 |
"""Shows info about node group.
|
|
292 |
|
|
293 |
"""
|
|
294 |
cl = GetClient()
|
|
295 |
selected_fields = ["name",
|
|
296 |
"ndparams", "custom_ndparams",
|
|
297 |
"diskparams", "custom_diskparams",
|
|
298 |
"ipolicy", "custom_ipolicy"]
|
|
299 |
result = cl.QueryGroups(names=args, fields=selected_fields,
|
|
300 |
use_locking=False)
|
|
301 |
|
|
302 |
for (name,
|
|
303 |
ndparams, custom_ndparams,
|
|
304 |
diskparams, custom_diskparams,
|
|
305 |
ipolicy, custom_ipolicy) in result:
|
|
306 |
ToStdout("Node group: %s" % name)
|
|
307 |
ToStdout(" Node parameters:")
|
|
308 |
ToStdout(_FormatDict(custom_ndparams, ndparams))
|
|
309 |
ToStdout(" Disk parameters:")
|
|
310 |
ToStdout(_FormatDict(custom_diskparams, diskparams))
|
|
311 |
ToStdout(" Instance policy:")
|
|
312 |
ToStdout(_FormatDict(custom_ipolicy, ipolicy))
|
|
313 |
|
|
314 |
|
276 |
315 |
commands = {
|
277 |
316 |
"add": (
|
278 |
317 |
AddGroup, ARGS_ONE_GROUP,
|
... | ... | |
323 |
362 |
RemoveTags, [ArgGroup(min=1, max=1), ArgUnknown()],
|
324 |
363 |
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT],
|
325 |
364 |
"<group_name> tag...", "Remove tags from the given group"),
|
|
365 |
"info": (
|
|
366 |
GroupInfo, ARGS_MANY_GROUPS, [], "<group_name>", "Show group information"),
|
326 |
367 |
}
|
327 |
368 |
|
328 |
369 |
|