From c1b42c18b914aa7ea650362ade7489448f71a523 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 28 May 2009 10:25:36 +0100 Subject: [PATCH] Upgrade be/hv params with default values 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/objects.py b/lib/objects.py index 2104156a9..dbcf32ec3 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -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 -- GitLab