From 2a27dac3623679b70c2e2a54543e7fa28fb23e37 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 27 Jan 2012 14:26:35 +0100 Subject: [PATCH] Fix upgrading of ndparams Currently, we only upgrade the ndparams if they are missing completely, which creates problems if we add any new parameters on an already-upgraded cluster. Fix this by adding an UpgradeNDParams function. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/objects.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/objects.py b/lib/objects.py index 537da3192..caa90b42a 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -165,6 +165,21 @@ def UpgradeDiskParams(diskparams): return result +def UpgradeNDParams(ndparams): + """Upgrade ndparams structure. + + @type ndparams: dict + @param ndparams: disk parameters to upgrade + @rtype: dict + @return: the upgraded node parameters dict + + """ + if ndparams is None: + ndparams = {} + + return FillDict(constants.NDC_DEFAULTS, ndparams) + + def MakeEmptyIPolicy(): """Create empty IPolicy dictionary. @@ -1473,8 +1488,7 @@ class Cluster(TaggableObject): if self.osparams is None: self.osparams = {} - if self.ndparams is None: - self.ndparams = constants.NDC_DEFAULTS + self.ndparams = UpgradeNDParams(self.ndparams) self.beparams = UpgradeGroupedParams(self.beparams, constants.BEC_DEFAULTS) -- GitLab