Commit 0e89fc2d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add “gnt-node modify-volume” command


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent efb8da02
......@@ -809,6 +809,31 @@ node5.example.com /dev/sdb1 698.6G 1.3G 697.4G
</para>
</refsect2>
<refsect2>
<title>MODIFY-VOLUME</title>
<cmdsynopsis>
<command>modify-volume</command>
<arg><option>--allocatable=yes|no</option></arg>
<sbr>
<arg><replaceable>node</replaceable></arg>
<arg><replaceable>storage-type</replaceable></arg>
<arg><replaceable>volume-name</replaceable></arg>
</cmdsynopsis>
<para>
Modifies storage volumes on a node. Only LVM physical volumes can be
modified at the moment. They have a storage type of <quote>lvm-pv</quote>.
</para>
<para>
Example:
<screen>
# gnt-node modify-volume --allocatable no node5.example.com lvm-pv /dev/sdb1
</screen>
</para>
</refsect2>
<refsect2>
<title>POWERCYCLE</title>
......
......@@ -59,6 +59,13 @@ _LIST_HEADERS = {
"role": "Role",
}
#: User-facing storage unit types
_USER_STORAGE_TYPE = {
constants.ST_FILE: "file",
constants.ST_LVM_PV: "lvm-pv",
constants.ST_LVM_VG: "lvm-vg",
}
@UsesRPC
def AddNode(opts, args):
......@@ -473,6 +480,36 @@ def ListPhysicalVolumes(opts, args):
return 0
def ModifyVolume(opts, args):
"""Modify storage volume on a node.
@param opts: the command line options selected by the user
@type args: list
@param args: should contain 3 items: node name, storage type and volume name
@rtype: int
@return: the desired exit code
"""
(node_name, user_storage_type, volume_name) = args
try:
storage_type = _USER_STORAGE_TYPE[user_storage_type]
except KeyError:
raise errors.OpPrereqError("Unknown storage type: %s" % user_storage_type)
changes = {}
if opts.allocatable is not None:
changes[constants.SF_ALLOCATABLE] = (opts.allocatable == "yes")
if changes:
op = opcodes.OpModifyNodeStorage(node_name=node_name,
storage_type=storage_type,
name=volume_name,
changes=changes)
SubmitOpCode(op)
def SetNodeParams(opts, args):
"""Modifies a node.
......@@ -583,7 +620,6 @@ commands = {
choices=('yes', 'no'), default=None,
metavar="yes|no",
help="Set the master_candidate flag on the node"),
make_option("-O", "--offline", dest="offline", metavar="yes|no",
choices=('yes', 'no'), default=None,
help="Set the offline flag on the node"),
......@@ -604,6 +640,15 @@ commands = {
FIELDS_OPT],
"[<node_name>...]",
"List physical volumes on node(s)"),
'modify-volume': (ModifyVolume, ARGS_FIXED(3),
[DEBUG_OPT,
make_option("--allocatable", dest="allocatable",
choices=["yes", "no"], default=None,
metavar="yes|no",
help="Set the allocatable flag on a volume"),
],
"<node_name> <storage_type> <name>",
"Modify storage volume on a node"),
'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