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

Add “gnt-node modify-volume” command

Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarGuido Trotter <>
parent efb8da02
......@@ -809,6 +809,31 @@ /dev/sdb1 698.6G 1.3G 697.4G
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>.
# gnt-node modify-volume --allocatable no lvm-pv /dev/sdb1
......@@ -59,6 +59,13 @@ _LIST_HEADERS = {
"role": "Role",
#: User-facing storage unit types
constants.ST_FILE: "file",
constants.ST_LVM_PV: "lvm-pv",
constants.ST_LVM_VG: "lvm-vg",
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
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,
def SetNodeParams(opts, args):
"""Modifies a node.
......@@ -583,7 +620,6 @@ commands = {
choices=('yes', 'no'), default=None,
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 = {
"List physical volumes on node(s)"),
'modify-volume': (ModifyVolume, ARGS_FIXED(3),
make_option("--allocatable", dest="allocatable",
choices=["yes", "no"], default=None,
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