diff --git a/lib/cli.py b/lib/cli.py index 7857e1810d6a7ac9c93b060f722f53a9b6d71bb6..0e7918ad37b953d73f6e9772eb4bca29da382509 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -122,6 +122,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", @@ -1067,6 +1068,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 2c056fb4f0213df61484227608e8dcc8e20a9d90..ca567830a672f2c72df97cc228ae8709d6892955 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -1294,7 +1294,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 @@ -1336,6 +1337,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, @@ -1536,7 +1538,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 d5c7d098c09ac36f28371405a3abebd906874d6a..c3d5742350fec9b5e157ff6f44cecc913cb7f3d3 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