Commit 4007f57d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Implement “gnt-node physical-volumes” command

This command can be used to list all physical volumes on nodes.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 9e5442ce
......@@ -721,6 +721,94 @@ /dev/hdc1 xenvg 256 inst
<arg rep="repeat"><replaceable>node</replaceable></arg>
Lists all physical volumes and their details from the node(s) provided.
The <option>--no-headers</option> option will skip the initial header
line. The <option>--separator</option> option takes an argument which
denotes what will be used between the output fields. Both these options
are to help scripting.
The units used to display the numeric values in the output varies,
depending on the options given. By default, the values will be
formatted in the most appropriate unit. If the
<option>--separator</option> option is given, then the values are shown
in mebibytes to allow parsing by scripts. In both cases, the
<option>--units</option> option can be used to enforce a given output
The <option>-o</option> option takes a comma-separated list of
output fields. The available fields and their meaning are:
<simpara>the node name on which the volume exists</simpara>
<simpara>the physical drive name</simpara>
<simpara>the physical drive size</simpara>
<simpara>used disk space</simpara>
<simpara>available disk space</simpara>
<simpara>whether physical volume is allocatable</simpara>
# gnt-node physical-volumes
Node Name Size Used Free /dev/sda7 673.8G 0M 673.8G /dev/sdb1 698.6G 1.3G 697.4G
......@@ -425,6 +425,54 @@ def ListVolumes(opts, args):
return 0
def ListPhysicalVolumes(opts, args):
"""List physical volumes on node(s).
@param opts: the command line options selected by the user
@type args: list
@param args: should either be an empty list, in which case
we list data for all nodes, or contain a list of nodes
to display data only for those
@rtype: int
@return: the desired exit code
if opts.output is None:
selected_fields = ["node", constants.SF_NAME, constants.SF_SIZE,
constants.SF_USED, constants.SF_FREE]
selected_fields = opts.output.split(",")
op = opcodes.OpQueryNodeStorage(nodes=args,
output = SubmitOpCode(op)
if not opts.no_headers:
headers = {
"node": "Node",
constants.SF_NAME: "Name",
constants.SF_SIZE: "Size",
constants.SF_USED: "Used",
constants.SF_FREE: "Free",
constants.SF_ALLOCATABLE: "Allocatable",
headers = None
unitfields = [constants.SF_SIZE, constants.SF_USED, constants.SF_FREE]
numfields = [constants.SF_SIZE, constants.SF_USED, constants.SF_FREE]
data = GenerateTable(separator=opts.separator, headers=headers,
fields=selected_fields, unitfields=unitfields,
numfields=numfields, data=output, units=opts.units)
for line in data:
return 0
def SetNodeParams(opts, args):
"""Modifies a node.
......@@ -551,6 +599,11 @@ commands = {
'volumes': (ListVolumes, ARGS_ANY,
"[<node_name>...]", "List logical volumes on node(s)"),
'physical-volumes': (ListPhysicalVolumes, ARGS_ANY,
"List physical volumes on node(s)"),
'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
"<node_name>", "List the tags of the given node"),
'add-tags': (AddTags, ARGS_ATLEAST(1), [DEBUG_OPT, TAG_SRC_OPT],
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment