Commit b4ec07f8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement --ignore-size in activate-disks

This patch modified OpActivateDisks, LUActivateDisks and gnt-instance
activate-disks to support and pass this option to

The patch is quite trivial I think; there should be no issues from it
except if used when not needed.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent e3443b36
......@@ -2592,12 +2592,16 @@ class LUActivateInstanceDisks(NoHooksLU):
assert self.instance is not None, \
"Cannot retrieve locked instance %s" % self.op.instance_name
_CheckNodeOnline(self, self.instance.primary_node)
if not hasattr(self.op, "ignore_size"):
self.op.ignore_size = False
def Exec(self, feedback_fn):
"""Activate the disks.
disks_ok, disks_info = _AssembleInstanceDisks(self, self.instance)
disks_ok, disks_info = \
_AssembleInstanceDisks(self, self.instance,
if not disks_ok:
raise errors.OpExecError("Cannot activate block devices")
......@@ -438,7 +438,7 @@ class OpActivateInstanceDisks(OpCode):
"""Activate an instance's disks."""
OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"]
__slots__ = ["instance_name", "ignore_size"]
class OpDeactivateInstanceDisks(OpCode):
......@@ -1657,6 +1657,7 @@ instance5: 11225
<arg choice="req"><replaceable>instance</replaceable></arg>
......@@ -1685,6 +1686,16 @@
<command>gnt-job info</command>.
The <option>--ignore-size</option> option can be used to
activate disks ignoring the currently configured size in
Ganeti. This can be used in cases where the configuration
has gotten out of sync with the real-world (e.g. after a
partially-failed grow-disk operation or due to rounding in
LVM devices). This should not be used in normal cases, but
only when activate-disks fails without it.
Note that it is safe to run this command while the instance
is already running.
......@@ -609,7 +609,8 @@ def ActivateDisks(opts, args):
instance_name = args[0]
op = opcodes.OpActivateInstanceDisks(instance_name=instance_name)
op = opcodes.OpActivateInstanceDisks(instance_name=instance_name,
disks_info = SubmitOrSend(op, opts)
for host, iname, nname in disks_info:
ToStdout("%s:%s:%s", host, iname, nname)
......@@ -1482,7 +1483,14 @@ commands = {
"<instance>", "Reboots an instance"),
'activate-disks': (ActivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
'activate-disks': (ActivateDisks, ARGS_ONE,
make_option("--ignore-size", dest="ignore_size",
default=False, action="store_true",
help="Ignore current recorded size"
" (useful for forcing activation when"
" the recorded size is wrong)"),
"Activate an instance's disks"),
'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment