From 38db4e7cd9b678d3e6fb09aebb1f7b50735e4b47 Mon Sep 17 00:00:00 2001 From: Adam Ingrassia <api@google.com> Date: Wed, 22 Feb 2012 10:31:26 -0500 Subject: [PATCH] Front-end and doc to use allocator in recreate-disks The recreate-disks command no longer requires an explicit list of nodes. Signed-off-by: Adam Ingrassia <api@google.com> Signed-off-by: Bernardo Dal Seno <bdalseno@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- doc/admin.rst | 4 +++- lib/client/gnt_instance.py | 9 +++++++-- man/gnt-instance.rst | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/admin.rst b/doc/admin.rst index d7f70f585..889124a58 100644 --- a/doc/admin.rst +++ b/doc/admin.rst @@ -667,7 +667,9 @@ command:: $ gnt-instance recreate-disks %INSTANCE% -Note that this will fail if the disks already exists. +Note that this will fail if the disks already exists. The instance can +be assigned to new nodes automatically by specifying an iallocator +through the ``--iallocator`` option. Conversion of an instance's disk type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 225e6d4e0..4e1eb57dc 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -630,6 +630,9 @@ def RecreateDisks(opts, args): # LUInstanceRecreateDisks, but it'd be nice to have in the client) if opts.node: + if opts.iallocator: + msg = "At most one of either --nodes or --iallocator can be passed" + raise errors.OpPrereqError(msg, errors.ECODE_INVAL) pnode, snode = SplitNodeOption(opts.node) nodes = [pnode] if snode is not None: @@ -638,7 +641,8 @@ def RecreateDisks(opts, args): nodes = [] op = opcodes.OpInstanceRecreateDisks(instance_name=instance_name, - disks=disks, nodes=nodes) + disks=disks, nodes=nodes, + iallocator=opts.iallocator) SubmitOrSend(op, opts) return 0 @@ -1638,7 +1642,8 @@ commands = { "[-f] <instance>", "Deactivate an instance's disks"), "recreate-disks": ( RecreateDisks, ARGS_ONE_INSTANCE, - [SUBMIT_OPT, DISK_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT], + [SUBMIT_OPT, DISK_OPT, NODE_PLACEMENT_OPT, DRY_RUN_OPT, PRIORITY_OPT, + IALLOCATOR_OPT], "<instance>", "Recreate an instance's disks"), "grow-disk": ( GrowDisk, diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index dfb6ed439..fa15a10bf 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -1428,7 +1428,8 @@ instance. RECREATE-DISKS ^^^^^^^^^^^^^^ -| **recreate-disks** [\--submit] [-n node1:[node2]] +| **recreate-disks** [\--submit] +| [{-n node1:[node2] \| {-I\|\--iallocator *name*}}] | [\--disk=*N*[:[size=*VAL*][,mode=*ro\|rw*]]] {*instance*} Recreates all or a subset of disks of the given instance. @@ -1454,6 +1455,11 @@ passed must equal the number of nodes that the instance currently has. Note that changing nodes is only allowed when all disks are replaced, e.g. when no ``--disk`` option is passed. +Another method of chosing which nodes to place the instance on is by +using the specified iallocator, passing the ``--iallocator`` option. +The primary and secondary nodes will be chosen by the specified +iallocator plugin. + See **ganeti(7)** for a description of ``--submit`` and other common options. -- GitLab