Skip to content
Snippets Groups Projects
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
No related merge requests found
...@@ -722,13 +722,14 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst ...@@ -722,13 +722,14 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
</refsect2> </refsect2>
<refsect2> <refsect2>
<title>VOLUMES</title> <title>PHYSICAL-VOLUMES</title>
<cmdsynopsis> <cmdsynopsis>
<command>physical-volumes</command> <command>physical-volumes</command>
<arg>--no-headers</arg> <arg>--no-headers</arg>
<arg>--human-readable</arg> <arg>--human-readable</arg>
<arg>--separator=<replaceable>SEPARATOR</replaceable></arg> <arg>--separator=<replaceable>SEPARATOR</replaceable></arg>
<arg>--storage-type=<replaceable>STORAGE_TYPE</replaceable></arg>
<arg>--output=<replaceable>FIELDS</replaceable></arg> <arg>--output=<replaceable>FIELDS</replaceable></arg>
<sbr> <sbr>
<arg rep="repeat"><replaceable>node</replaceable></arg> <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 ...@@ -755,6 +756,13 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
unit. unit.
</para> </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> <para>
The <option>-o</option> option takes a comma-separated list of The <option>-o</option> option takes a comma-separated list of
output fields. The available fields and their meaning are: 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 ...@@ -774,25 +782,37 @@ node1.example.com /dev/hdc1 xenvg instance1.example.com-sda_11001.data 256 inst
<varlistentry> <varlistentry>
<term>size</term> <term>size</term>
<listitem> <listitem>
<simpara>the physical drive size</simpara> <simpara>
the physical drive size
(<literal>lvm-pv</literal> and <literal>lvm-vg</literal> only)
</simpara>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>used</term> <term>used</term>
<listitem> <listitem>
<simpara>used disk space</simpara> <simpara>
used disk space
(<literal>lvm-pv</literal> and <literal>file</literal> only)
</simpara>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>free</term> <term>free</term>
<listitem> <listitem>
<simpara>available disk space</simpara> <simpara>
available disk space
(<literal>lvm-pv</literal> and <literal>file</literal> only)
</simpara>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>allocatable</term> <term>allocatable</term>
<listitem> <listitem>
<simpara>whether physical volume is allocatable</simpara> <simpara>
whether physical volume is allocatable
(<literal>lvm-pv</literal> only)
</simpara>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
......
...@@ -444,14 +444,41 @@ def ListPhysicalVolumes(opts, args): ...@@ -444,14 +444,41 @@ def ListPhysicalVolumes(opts, args):
@return: the desired exit code @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: if opts.output is None:
selected_fields = ["node", constants.SF_NAME, constants.SF_SIZE, selected_fields = ["node"]
constants.SF_USED, constants.SF_FREE] selected_fields.extend(default_fields[storage_type])
else: else:
selected_fields = opts.output.split(",") selected_fields = opts.output.split(",")
op = opcodes.OpQueryNodeStorage(nodes=args, op = opcodes.OpQueryNodeStorage(nodes=args,
storage_type=constants.ST_LVM_PV, storage_type=storage_type,
output_fields=selected_fields) output_fields=selected_fields)
output = SubmitOpCode(op) output = SubmitOpCode(op)
...@@ -637,7 +664,15 @@ commands = { ...@@ -637,7 +664,15 @@ commands = {
"[<node_name>...]", "List logical volumes on node(s)"), "[<node_name>...]", "List logical volumes on node(s)"),
'physical-volumes': (ListPhysicalVolumes, ARGS_ANY, 'physical-volumes': (ListPhysicalVolumes, ARGS_ANY,
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, [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>...]", "[<node_name>...]",
"List physical volumes on node(s)"), "List physical volumes on node(s)"),
'modify-volume': (ModifyVolume, ARGS_FIXED(3), 'modify-volume': (ModifyVolume, ARGS_FIXED(3),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment