Commit 6e34b628 authored by Guido Trotter's avatar Guido Trotter
Browse files

Abstract Param upgrade from cluster.UpgradeConfig



A new UpgradeGroupedParams is used to upgrade all the profiles for one
parameter filling in the default values, or creating the whole dict
anew, should it be missing. This is used only for beparams, currently,
but will be used at least for nicparams and diskparams as well.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4ef7f423
......@@ -54,6 +54,24 @@ def FillDict(defaults_dict, custom_dict):
ret_dict.update(custom_dict)
return ret_dict
def UpgradeGroupedParams(target, defaults):
"""Update all groups for the target parameter.
@type target: dict of dicts
@param target: {group: {parameter: value}}
@type defaults: dict
@param defaults: default parameter values
"""
if target is None:
target = {constants.PP_DEFAULT: defaults}
else:
for group in target:
target[group] = FillDict(defaults, target[group])
return target
class ConfigObject(object):
"""A generic config object.
......@@ -763,12 +781,8 @@ class Cluster(TaggableObject):
self.hvparams[hypervisor] = FillDict(
constants.HVC_DEFAULTS[hypervisor], self.hvparams[hypervisor])
if self.beparams is None:
self.beparams = {constants.PP_DEFAULT: constants.BEC_DEFAULTS}
else:
for begroup in self.beparams:
self.beparams[begroup] = FillDict(constants.BEC_DEFAULTS,
self.beparams[begroup])
self.beparams = UpgradeGroupedParams(self.beparams,
constants.BEC_DEFAULTS)
if self.modify_etc_hosts is None:
self.modify_etc_hosts = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment