Extend gnt-instance modify by a new parameter --new-primary that sets the pnode paramter of the opcode.
Signed-off-by: Klaus Aehlig <aeh...@google.com> --- lib/cli.py | 6 ++++++ lib/client/gnt_instance.py | 6 ++++-- man/gnt-instance.rst | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 34657a0..e901dc0 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -121,6 +121,7 @@ __all__ = [ "NEW_CLUSTER_DOMAIN_SECRET_OPT", "NEW_CONFD_HMAC_KEY_OPT", "NEW_RAPI_CERT_OPT", + "NEW_PRIMARY_OPT", "NEW_SECONDARY_OPT", "NEW_SPICE_CERT_OPT", "NIC_PARAMS_OPT", @@ -1064,6 +1065,11 @@ NEW_SECONDARY_OPT = cli_option("-n", "--new-secondary", dest="dst_node", metavar="NODE", default=None, completion_suggest=OPT_COMPL_ONE_NODE) +NEW_PRIMARY_OPT = cli_option("--new-primary", dest="new_primary_node", + help="Specifies the new primary node", + metavar="<node>", default=None, + completion_suggest=OPT_COMPL_ONE_NODE) + ON_PRIMARY_OPT = cli_option("-p", "--on-primary", dest="on_primary", default=False, action="store_true", help="Replace the disk(s) on the primary" diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 4f1538d..e592e77 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -1291,7 +1291,8 @@ def SetInstanceParams(opts, args): """ if not (opts.nics or opts.disks or opts.disk_template or opts.hvparams or opts.beparams or opts.os or opts.osparams or - opts.offline_inst or opts.online_inst or opts.runtime_mem): + opts.offline_inst or opts.online_inst or opts.runtime_mem or + opts.new_primary_node): ToStderr("Please give at least one of the parameters.") return 1 @@ -1333,6 +1334,7 @@ def SetInstanceParams(opts, args): disks=disks, disk_template=opts.disk_template, remote_node=opts.node, + pnode=opts.new_primary_node, hvparams=opts.hvparams, beparams=opts.beparams, runtime_mem=opts.runtime_mem, @@ -1533,7 +1535,7 @@ commands = { DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT, ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT, - NOCONFLICTSCHECK_OPT], + NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT], "<instance>", "Alters the parameters of an instance"), "shutdown": ( GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()], diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index d5c7d09..c3d5742 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -1032,6 +1032,7 @@ MODIFY | \--disk [*N*:]remove \| | \--disk *N*:mode=*MODE*] | [{-t|\--disk-template} plain | {-t|\--disk-template} drbd -n *new_secondary*] [\--no-wait-for-sync] +| [\--new-primary=*node*] | [\--os-type=*OS* [\--force-variant]] | [{-O|\--os-parameters} *param*=*value*... ] | [\--offline \| \--online] @@ -1090,6 +1091,11 @@ not found, then by default the modification is refused, unless ``--force-variant`` is passed. An invalid OS will also be refused, unless the ``--force`` option is given. +The option ``--new-primary`` will set the new primary node of an instance +assuming the disks have already been moved manually. Unless the ``--force`` +option is given, it is verified that the instance is no longer running +on its current primary node. + The ``--online`` and ``--offline`` options are used to transition an instance into and out of the ``offline`` state. An instance can be turned offline only if it was previously down. The ``--online`` option -- 1.8.1.3