From c9c41373b52bd354b47fd6a4682daa5d03e3367f Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Wed, 26 Jan 2011 17:45:10 +0100 Subject: [PATCH] Deactivate disks: allow skipping hypervisor checks In some cases (e.g. the hypervisor not running at all), we might want to force disk deactivation, skipping the hypervisor checks. I believe this is not a good thing to do all the time, so this patch adds the force option to allow manual selection of this operation mode. Signed-off-by: Iustin Pop Reviewed-by: Michael Hanselmann --- lib/client/gnt_instance.py | 7 ++++--- lib/cmdlib.py | 5 ++++- lib/opcodes.py | 3 ++- man/gnt-instance.rst | 9 ++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 7f12d92..48c2e3f 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -611,7 +611,8 @@ def DeactivateDisks(opts, args): """ instance_name = args[0] - op = opcodes.OpInstanceDeactivateDisks(instance_name=instance_name) + op = opcodes.OpInstanceDeactivateDisks(instance_name=instance_name, + force=opts.force) SubmitOrSend(op, opts) return 0 @@ -1465,8 +1466,8 @@ commands = { "", "Activate an instance's disks"), 'deactivate-disks': ( DeactivateDisks, ARGS_ONE_INSTANCE, - [SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], - "", "Deactivate an instance's disks"), + [FORCE_OPT, SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT], + "[-f] ", "Deactivate an instance's disks"), 'recreate-disks': ( RecreateDisks, ARGS_ONE_INSTANCE, [SUBMIT_OPT, DISKIDX_OPT, DRY_RUN_OPT, PRIORITY_OPT], diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 51e94ff..e129a35 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -4822,7 +4822,10 @@ class LUInstanceDeactivateDisks(NoHooksLU): """ instance = self.instance - _SafeShutdownInstanceDisks(self, instance) + if self.op.force: + _ShutdownInstanceDisks(self, instance) + else: + _SafeShutdownInstanceDisks(self, instance) def _SafeShutdownInstanceDisks(lu, instance, disks=None): diff --git a/lib/opcodes.py b/lib/opcodes.py index 288f2e5..0293ba4 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -941,7 +941,8 @@ class OpInstanceDeactivateDisks(OpCode): """Deactivate an instance's disks.""" OP_DSC_FIELD = "instance_name" OP_PARAMS = [ - _PInstanceName + _PInstanceName, + _PForce, ] diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index be3f7d5..9179ad9 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -1242,7 +1242,7 @@ already running. DEACTIVATE-DISKS ^^^^^^^^^^^^^^^^ -**deactivate-disks** [--submit] {*instance*} +**deactivate-disks** [-f] [--submit] {*instance*} De-activates the block devices of the given instance. Note that if you run this command for an instance with a drbd disk template, @@ -1250,6 +1250,13 @@ while it is running, it will not be able to shutdown the block devices on the primary node, but it will shutdown the block devices on the secondary nodes, thus breaking the replication. +The ``-f``/``--force`` option will skip checks that the instance is +down; in case the hypervisor is confused and we can't talk to it, +normally Ganeti will refuse to deactivate the disks, but with this +option passed it will skip this check and directly try to deactivate +the disks. This can still fail due to the instance actually running or +other issues. + The ``--submit`` option is used to send the job to the master daemon but not wait for its completion. The job ID will be shown so that it can be examined via **gnt-job info**. -- 1.7.10.4