From 9b64e486bb341316cbe64b06daf37fe6ca14d60f Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 13 May 2011 17:02:35 +0200
Subject: [PATCH] Introduce instance start/stop no_remember attribute
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This will allow stopping or starting an instance without changing the
remembered state. While this seems counter-intuitive at first (it will
create cluster verify errors), it can help in a few corner cases:

- shutting down an entire cluster for maintenance but without having
  to remember state
- doing testing of Ganeti itself

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/cmdlib.py  | 6 ++++--
 lib/opcodes.py | 5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 8b2374c2c..c95cdfd48 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5191,7 +5191,8 @@ class LUInstanceStartup(LogicalUnit):
     instance = self.instance
     force = self.op.force
 
-    self.cfg.MarkInstanceUp(instance.name)
+    if not self.op.no_remember:
+      self.cfg.MarkInstanceUp(instance.name)
 
     if self.primary_offline:
       assert self.op.ignore_offline_nodes
@@ -5332,7 +5333,8 @@ class LUInstanceShutdown(LogicalUnit):
     node_current = instance.primary_node
     timeout = self.op.timeout
 
-    self.cfg.MarkInstanceDown(instance.name)
+    if not self.op.no_remember:
+      self.cfg.MarkInstanceDown(instance.name)
 
     if self.primary_offline:
       assert self.op.ignore_offline_nodes
diff --git a/lib/opcodes.py b/lib/opcodes.py
index d04c969e7..b89444d3e 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -81,6 +81,9 @@ _PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString))
 #: Ignore consistency
 _PIgnoreConsistency = ("ignore_consistency", False, ht.TBool)
 
+#: Do not remember instance state changes
+_PNoRemember = ("no_remember", False, ht.TBool)
+
 #: OP_ID conversion regular expression
 _OPID_RE = re.compile("([a-z])([A-Z])")
 
@@ -837,6 +840,7 @@ class OpInstanceStartup(OpCode):
     _PInstanceName,
     _PForce,
     _PIgnoreOfflineNodes,
+    _PNoRemember,
     ("hvparams", ht.EmptyDict, ht.TDict),
     ("beparams", ht.EmptyDict, ht.TDict),
     ]
@@ -848,6 +852,7 @@ class OpInstanceShutdown(OpCode):
   OP_PARAMS = [
     _PInstanceName,
     _PIgnoreOfflineNodes,
+    _PNoRemember,
     ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt),
     ]
 
-- 
GitLab