From 0e89fc2dc2181573918fdec35674095a072e11bc Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 30 Jul 2009 16:44:21 +0200 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9Cgnt-node=20modify-volume?= =?UTF-8?q?=E2=80=9D=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- man/gnt-node.sgml | 25 +++++++++++++++++++++++++ scripts/gnt-node | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/man/gnt-node.sgml b/man/gnt-node.sgml index d7d9f852c..cc4298533 100644 --- a/man/gnt-node.sgml +++ b/man/gnt-node.sgml @@ -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> diff --git a/scripts/gnt-node b/scripts/gnt-node index 6141e5027..92da879bf 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -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], -- GitLab