diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 7f12d9252ef7255bd7d210955120f2a9cddc0061..48c2e3fab6dec78f8ec92cea39f287743576589c 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 51e94ff298b9d5b6170801a2a035be199adefedb..e129a3541980871580e424eff7b84f15d6acd2bc 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 288f2e5a7056392ed8e4e65fb5b8e92e6548ab7b..0293ba401c0a7b4542802f44b5eb7a7e43fab621 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 be3f7d52a0403dda6d267b135f46a2e25163f833..9179ad93bb11f52ae35a55c8404975e307ffca3e 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**.