Upgrade be/hv params with default values
authorGuido Trotter <ultrotter@google.com>
Thu, 28 May 2009 09:25:36 +0000 (10:25 +0100)
committerGuido Trotter <ultrotter@google.com>
Thu, 28 May 2009 12:18:03 +0000 (13:18 +0100)
From time to time we're adding new be or hv parameters. With this patch
missing parameters get set to the default value when loading the cluster
object. This patch version also considers the case when hv/be params
don't exist at all, and fixes a broken unit test triggered in that
case.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/objects.py

index 2104156..dbcf32e 100644 (file)
@@ -742,6 +742,20 @@ class Cluster(TaggableObject):
     """Fill defaults for missing configuration values.
 
     """
+    if self.hvparams is None:
+      self.hvparams = constants.HVC_DEFAULTS
+    else:
+      for hypervisor in self.hvparams:
+        self.hvparams[hypervisor] = self.FillDict(
+            constants.HVC_DEFAULTS[hypervisor], self.hvparams[hypervisor])
+
+    if self.beparams is None:
+      self.beparams = {constants.BEGR_DEFAULT: constants.BEC_DEFAULTS}
+    else:
+      for begroup in self.beparams:
+        self.beparams[begroup] = self.FillDict(constants.BEC_DEFAULTS,
+                                               self.beparams[begroup])
+
     if self.modify_etc_hosts is None:
       self.modify_etc_hosts = True