Commit b0a383aa authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Klaus Aehlig

Fix handling of the --online option

From the man page, the --online option is supposed to mark an
instance down only if it is already offline. Otherwise it should
fail. With this patch we avoid undesired transitions to ADMIN_down
state while the instance is already up and running.

Fix the corresponding QA test as well (TestInstanceModify).
Signed-off-by: default avatarDimitris Aragiorgis <>
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarKlaus Aehlig <>
parent b0d1e392
......@@ -2849,9 +2849,14 @@ class LUInstanceSetParams(LogicalUnit):
ispec[constants.ISPEC_DISK_COUNT] = len(disk_sizes)
ispec[constants.ISPEC_DISK_SIZE] = disk_sizes
if self.op.offline is not None and self.op.offline:
# either --online or --offline was passed
if self.op.offline is not None:
if self.op.offline:
msg = "can't change to offline without being down first"
msg = "can't change to online (down) without being offline first"
CheckInstanceState(self, self.instance, CAN_CHANGE_INSTANCE_OFFLINE,
msg="can't change to offline")
def CheckPrereq(self):
"""Check prerequisites.
......@@ -554,8 +554,9 @@ def TestInstanceModify(instance):
AssertCommand(["gnt-instance", "modify", "--offline",],
# ...while making it online is ok, and should work
AssertCommand(["gnt-instance", "modify", "--online",])
# ...while making it online fails too (needs to be offline first)
AssertCommand(["gnt-instance", "modify", "--online",],
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