From 7228ca91822334653d3b0264d80d1307a93a1515 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Mon, 14 May 2012 10:32:09 +0200
Subject: [PATCH] gnt-group add: Fix diskparam fill
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This was a pretty non-obvious bug. A cluster looks sane after
gnt-cluster init, however on a daemon restart the diskparameters had the
default filled in. The same applies to gnt-group add. This is due to the
nature that UpgradeConfig() from NodeGroups did just populate them with
defaults if something was set on it.

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

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 5b065e813..5eae4a85e 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -13589,7 +13589,7 @@ class LUGroupAdd(LogicalUnit):
                               constants.DISK_DT_TYPES)
       self.new_diskparams = self.op.diskparams
     else:
-      self.new_diskparams = None
+      self.new_diskparams = {}
 
     if self.op.ipolicy:
       cluster = self.cfg.GetClusterInfo()
diff --git a/lib/objects.py b/lib/objects.py
index 8cc31e794..9b086ded9 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -1496,7 +1496,8 @@ class NodeGroup(TaggableObject):
     if self.mtime is None:
       self.mtime = time.time()
 
-    self.diskparams = UpgradeDiskParams(self.diskparams)
+    if self.diskparams is None:
+      self.diskparams = {}
     if self.ipolicy is None:
       self.ipolicy = MakeEmptyIPolicy()
 
-- 
GitLab