Revision 4007f57d scripts/gnt-node
b/scripts/gnt-node | ||
---|---|---|
425 | 425 |
return 0 |
426 | 426 |
|
427 | 427 |
|
428 |
def ListPhysicalVolumes(opts, args): |
|
429 |
"""List physical volumes on node(s). |
|
430 |
|
|
431 |
@param opts: the command line options selected by the user |
|
432 |
@type args: list |
|
433 |
@param args: should either be an empty list, in which case |
|
434 |
we list data for all nodes, or contain a list of nodes |
|
435 |
to display data only for those |
|
436 |
@rtype: int |
|
437 |
@return: the desired exit code |
|
438 |
|
|
439 |
""" |
|
440 |
if opts.output is None: |
|
441 |
selected_fields = ["node", constants.SF_NAME, constants.SF_SIZE, |
|
442 |
constants.SF_USED, constants.SF_FREE] |
|
443 |
else: |
|
444 |
selected_fields = opts.output.split(",") |
|
445 |
|
|
446 |
op = opcodes.OpQueryNodeStorage(nodes=args, |
|
447 |
storage_type=constants.ST_LVM_PV, |
|
448 |
output_fields=selected_fields) |
|
449 |
output = SubmitOpCode(op) |
|
450 |
|
|
451 |
if not opts.no_headers: |
|
452 |
headers = { |
|
453 |
"node": "Node", |
|
454 |
constants.SF_NAME: "Name", |
|
455 |
constants.SF_SIZE: "Size", |
|
456 |
constants.SF_USED: "Used", |
|
457 |
constants.SF_FREE: "Free", |
|
458 |
constants.SF_ALLOCATABLE: "Allocatable", |
|
459 |
} |
|
460 |
else: |
|
461 |
headers = None |
|
462 |
|
|
463 |
unitfields = [constants.SF_SIZE, constants.SF_USED, constants.SF_FREE] |
|
464 |
numfields = [constants.SF_SIZE, constants.SF_USED, constants.SF_FREE] |
|
465 |
|
|
466 |
data = GenerateTable(separator=opts.separator, headers=headers, |
|
467 |
fields=selected_fields, unitfields=unitfields, |
|
468 |
numfields=numfields, data=output, units=opts.units) |
|
469 |
|
|
470 |
for line in data: |
|
471 |
ToStdout(line) |
|
472 |
|
|
473 |
return 0 |
|
474 |
|
|
475 |
|
|
428 | 476 |
def SetNodeParams(opts, args): |
429 | 477 |
"""Modifies a node. |
430 | 478 |
|
... | ... | |
551 | 599 |
'volumes': (ListVolumes, ARGS_ANY, |
552 | 600 |
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], |
553 | 601 |
"[<node_name>...]", "List logical volumes on node(s)"), |
602 |
'physical-volumes': (ListPhysicalVolumes, ARGS_ANY, |
|
603 |
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, |
|
604 |
FIELDS_OPT], |
|
605 |
"[<node_name>...]", |
|
606 |
"List physical volumes on node(s)"), |
|
554 | 607 |
'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT], |
555 | 608 |
"<node_name>", "List the tags of the given node"), |
556 | 609 |
'add-tags': (AddTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT], |
Also available in: Unified diff