diff --git a/man/gnt-node.sgml b/man/gnt-node.sgml index cc4298533d48c918207b16210c4c53a184e8613e..5180cd79b459f605abc7556289e7e44996962dd9 100644 --- a/man/gnt-node.sgml +++ b/man/gnt-node.sgml @@ -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> diff --git a/scripts/gnt-node b/scripts/gnt-node index 92da879bfe8a08aea3a4c590827c9ae231af1c66..cf2419068f28f41454344592d7e1425fde155da5 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -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),