From eec7840a78aed6a8a2d2218b478c6360e6953c49 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 19 Dec 2012 10:05:26 +0100
Subject: [PATCH] Allow running instances to be put online

If an instance is running (eg. ERROR_up) and at the same time offline,
there's no way to either shut it down or reonline it. This allows
onlining it. Offlining is still disabled for running instances.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index aa3740f12..8360b83dd 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -13419,12 +13419,9 @@ 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:
-      if self.op.offline:
-        msg = "can't change to offline"
-      else:
-        msg = "can't change to online"
-      _CheckInstanceState(self, instance, CAN_CHANGE_INSTANCE_OFFLINE, msg=msg)
+    if self.op.offline is not None and self.op.offline:
+      _CheckInstanceState(self, instance, CAN_CHANGE_INSTANCE_OFFLINE,
+                          msg="can't change to offline")
 
     # Pre-compute NIC changes (necessary to use result in hooks)
     self._nic_chgdesc = []
-- 
GitLab