From 885a0fc4637bc0e5c9f3c36422725068024c41a6 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 13 May 2011 17:17:44 +0200 Subject: [PATCH] Implement no_remember at CLI level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- lib/cli.py | 7 +++++++ lib/client/gnt_instance.py | 11 +++++++---- man/gnt-instance.rst | 19 +++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index 61c0e14fa..766981eae 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -126,6 +126,7 @@ __all__ = [ "NOSTART_OPT", "NOSSH_KEYCHECK_OPT", "NOVOTING_OPT", + "NO_REMEMBER_OPT", "NWSYNC_OPT", "ON_PRIMARY_OPT", "ON_SECONDARY_OPT", @@ -1149,6 +1150,12 @@ NODE_POWERED_OPT = cli_option("--node-powered", default=None, dest="node_powered", help="Specify if the SoR for node is powered") +NO_REMEMBER_OPT = cli_option("--no-remember", + dest="no_remember", + action="store_true", default=False, + help="Perform but do not record the change" + " in the configuration") + #: Options provided by all commands COMMON_OPTS = [DEBUG_OPT] diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 3ee4b85b1..ba9895cb8 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -692,7 +692,8 @@ def _StartupInstance(name, opts): """ op = opcodes.OpInstanceStartup(instance_name=name, force=opts.force, - ignore_offline_nodes=opts.ignore_offline) + ignore_offline_nodes=opts.ignore_offline, + no_remember=opts.no_remember) # do not add these parameters to the opcode unless they're defined if opts.hvparams: op.hvparams = opts.hvparams @@ -731,7 +732,8 @@ def _ShutdownInstance(name, opts): """ return opcodes.OpInstanceShutdown(instance_name=name, timeout=opts.timeout, - ignore_offline_nodes=opts.ignore_offline) + ignore_offline_nodes=opts.ignore_offline, + no_remember=opts.no_remember) def ReplaceDisks(opts, args): @@ -1457,14 +1459,15 @@ commands = { [m_node_opt, m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, m_inst_opt, m_force_multi, TIMEOUT_OPT, SUBMIT_OPT, - DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT], + DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, NO_REMEMBER_OPT], "<instance>", "Stops an instance"), 'startup': ( GenericManyOps("startup", _StartupInstance), [ArgInstance()], [FORCE_OPT, m_force_multi, m_node_opt, m_pri_node_opt, m_sec_node_opt, m_node_tags_opt, m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, m_clust_opt, m_inst_opt, SUBMIT_OPT, HVOPTS_OPT, - BACKEND_OPT, DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT], + BACKEND_OPT, DRY_RUN_OPT, PRIORITY_OPT, IGNORE_OFFLINE_OPT, + NO_REMEMBER_OPT], "<instance>", "Starts an instance"), 'reboot': ( GenericManyOps("reboot", _RebootInstance), [ArgInstance()], diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 0d6dde511..f4dc84e06 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -989,7 +989,7 @@ STARTUP | **startup** | [--force] [--ignore-offline] -| [--force-multiple] +| [--force-multiple] [--no-remember] | [--instance \| --node \| --primary \| --secondary \| --all \| | --tags \| --node-tags \| --pri-node-tags \| --sec-node-tags] | [{-H|--hypervisor-parameters} ``key=value...``] @@ -1047,6 +1047,12 @@ mark the instance as started even if the primary is not available. The ``--force-multiple`` will skip the interactive confirmation in the case the more than one instance will be affected. +The ``--no-remember`` option will perform the startup but not change +the state of the instance in the configuration file (if it was stopped +before, Ganeti will still thinks it needs to be stopped). This can be +used for testing, or for a one shot-start where you don't want the +watcher to restart the instance if it crashes. + The ``-H (--hypervisor-parameters)`` and ``-B (--backend-parameters)`` options specify temporary hypervisor and backend parameters that can be used to start an instance with modified parameters. They can be @@ -1079,7 +1085,7 @@ SHUTDOWN | **shutdown** | [--timeout=*N*] -| [--force-multiple] [--ignore-offline] +| [--force-multiple] [--ignore-offline] [--no-remember] | [--instance \| --node \| --primary \| --secondary \| --all \| | --tags \| --node-tags \| --pri-node-tags \| --sec-node-tags] | [--submit] @@ -1108,6 +1114,15 @@ can be examined via **gnt-job info**. force the instance to be marked as stopped. This option should be used with care as it can lead to an inconsistent cluster state. +The ``--no-remember`` option will perform the shutdown but not change +the state of the instance in the configuration file (if it was running +before, Ganeti will still thinks it needs to be running). This can be +useful for a cluster-wide shutdown, where some instances are marked as +up and some as down, and you don't want to change the running state: +you just need to disable the watcher, shutdown all instances with +``--no-remember``, and when the watcher is activated again it will +restore the correct runtime state for all instances. + Example:: # gnt-instance shutdown instance1.example.com -- GitLab