Commit 53548798 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-node physical-volumes: Add storage type parameter



This way the user can also show storage types other than lvm-pv.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent a4d138b7
......@@ -722,13 +722,14 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
</refsect2>
<refsect2>
<title>VOLUMES</title>
<title>PHYSICAL-VOLUMES</title>
<cmdsynopsis>
<command>physical-volumes</command>
<arg>--no-headers</arg>
<arg>--human-readable</arg>
<arg>--separator=<replaceable>SEPARATOR</replaceable></arg>
<arg>--storage-type=<replaceable>STORAGE_TYPE</replaceable></arg>
<arg>--output=<replaceable>FIELDS</replaceable></arg>
<sbr>
<arg rep="repeat"><replaceable>node</replaceable></arg>
......@@ -755,6 +756,13 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
unit.
</para>
<para>
The <option>--storage-type</option> option can be used to choose a
storage unit type. Possible choices are <literal>lvm-pv</literal>,
<literal>lvm-vg</literal> or <literal>file</literal>. Depending on the
storage type, the available output fields change.
</para>
<para>
The <option>-o</option> option takes a comma-separated list of
output fields. The available fields and their meaning are:
......@@ -774,25 +782,37 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
<varlistentry>
<term>size</term>
<listitem>
<simpara>the physical drive size</simpara>
<simpara>
the physical drive size
(<literal>lvm-pv</literal> and <literal>lvm-vg</literal> only)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>used</term>
<listitem>
<simpara>used disk space</simpara>
<simpara>
used disk space
(<literal>lvm-pv</literal> and <literal>file</literal> only)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>free</term>
<listitem>
<simpara>available disk space</simpara>
<simpara>
available disk space
(<literal>lvm-pv</literal> and <literal>file</literal> only)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>allocatable</term>
<listitem>
<simpara>whether physical volume is allocatable</simpara>
<simpara>
whether physical volume is allocatable
(<literal>lvm-pv</literal> only)
</simpara>
</listitem>
</varlistentry>
</variablelist>
......
......@@ -444,14 +444,41 @@ def ListPhysicalVolumes(opts, args):
@return: the desired exit code
"""
# TODO: Default to ST_FILE if LVM is disabled on the cluster
if opts.user_storage_type is None:
opts.user_storage_type = constants.ST_LVM_PV
try:
storage_type = _USER_STORAGE_TYPE[opts.user_storage_type]
except KeyError:
raise errors.OpPrereqError("Unknown storage type: %s" % user_storage_type)
default_fields = {
constants.ST_FILE: [
constants.SF_NAME,
constants.SF_USED,
constants.SF_FREE,
],
constants.ST_LVM_PV: [
constants.SF_NAME,
constants.SF_SIZE,
constants.SF_USED,
constants.SF_FREE,
],
constants.ST_LVM_VG: [
constants.SF_NAME,
constants.SF_SIZE,
],
}
if opts.output is None:
selected_fields = ["node", constants.SF_NAME, constants.SF_SIZE,
constants.SF_USED, constants.SF_FREE]
selected_fields = ["node"]
selected_fields.extend(default_fields[storage_type])
else:
selected_fields = opts.output.split(",")
op = opcodes.OpQueryNodeStorage(nodes=args,
storage_type=constants.ST_LVM_PV,
storage_type=storage_type,
output_fields=selected_fields)
output = SubmitOpCode(op)
......@@ -637,7 +664,15 @@ commands = {
"[<node_name>...]", "List logical volumes on node(s)"),
'physical-volumes': (ListPhysicalVolumes, ARGS_ANY,
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT,
FIELDS_OPT],
FIELDS_OPT,
make_option("--storage-type",
dest="user_storage_type",
choices=_USER_STORAGE_TYPE.keys(),
default=None,
metavar="STORAGE_TYPE",
help=("Storage type (%s)" %
utils.CommaJoin(_USER_STORAGE_TYPE.keys()))),
],
"[<node_name>...]",
"List physical volumes on node(s)"),
'modify-volume': (ModifyVolume, ARGS_FIXED(3),
......
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