From: Guido Trotter <ultrot...@google.com>

>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 <ultrot...@google.com>
Reviewed-by: Iustin Pop <ius...@google.com>
(cherry picked from commit c1b42c18b914aa7ea650362ade7489448f71a523)
---
 lib/objects.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/objects.py b/lib/objects.py
index 13e78dd..d5f446e 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -759,6 +759,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
 
-- 
1.6.3.3

Reply via email to