From 455a344534b076aca01c626ddf1c81946cd899de Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 21 Apr 2008 13:22:16 +0000
Subject: [PATCH] Only change instance status if not already so

This patch makes the _SetInstanceStatus only change the status of the
instance (in the config file) if it's not already in the desired state.
This skips the increase of the config serial no without actual data
changes.

Reviewed-by: ultrotter
---
 lib/config.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/config.py b/lib/config.py
index f0e75e446..dcd6b6b32 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -319,8 +319,9 @@ class ConfigWriter:
       raise errors.ConfigurationError("Unknown instance '%s'" %
                                       instance_name)
     instance = self._config_data.instances[instance_name]
-    instance.status = status
-    self._WriteConfig()
+    if instance.status != status:
+      instance.status = status
+      self._WriteConfig()
 
   def MarkInstanceUp(self, instance_name):
     """Mark the instance status to up in the config.
-- 
GitLab