diff --git a/lib/bootstrap.py b/lib/bootstrap.py index 2f6f985df512b4f29e0970ab17c5d72a19fe321c..bc4fd1541217714502d9b07f7ce926362e958919 100644 --- a/lib/bootstrap.py +++ b/lib/bootstrap.py @@ -410,6 +410,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913 dirs = [(constants.RUN_GANETI_DIR, constants.RUN_DIRS_MODE)] utils.EnsureDirs(dirs) + objects.UpgradeBeParams(beparams) utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES) utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES) objects.NIC.CheckParameterSyntax(nicparams) diff --git a/lib/cli.py b/lib/cli.py index 5d6656739d87e03331b191965fccd62d8ffe13ff..63f2dfb4e82a80f8c9ec5902be7ede88291d0ecc 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -2212,7 +2212,7 @@ def GenericInstanceCreate(mode, opts, args): else: tags = [] - utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES) + utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_COMPAT) utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES) if mode == constants.INSTANCE_CREATE: diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index 3de05c2a933c75521b35e1756bb775a4503ce246..0410c54b96ef76b3e6330705f396aaf671bdc416 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -100,7 +100,7 @@ def InitCluster(opts, args): # prepare beparams dict beparams = objects.FillDict(constants.BEC_DEFAULTS, beparams) - utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES) + utils.ForceDictType(beparams, constants.BES_PARAMETER_COMPAT) # prepare nicparams dict nicparams = objects.FillDict(constants.NICC_DEFAULTS, nicparams) @@ -917,7 +917,7 @@ def SetClusterParams(opts, args): utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES) beparams = opts.beparams - utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES) + utils.ForceDictType(beparams, constants.BES_PARAMETER_COMPAT) nicparams = opts.nicparams utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES) diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index 15cd5967cc6d1bd685dff15c7f18d4abf0661d33..55f30728be6fabefb0363ec7ca0b85a94e68aad2 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -357,7 +357,7 @@ def BatchCreate(opts, args): (elem, name, err), errors.ECODE_INVAL) disks.append({"size": size}) - utils.ForceDictType(specs["backend"], constants.BES_PARAMETER_TYPES) + utils.ForceDictType(specs["backend"], constants.BES_PARAMETER_COMPAT) utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES) tmp_nics = [] @@ -1266,7 +1266,7 @@ def SetInstanceParams(opts, args): if opts.beparams[param].lower() == "default": opts.beparams[param] = constants.VALUE_DEFAULT - utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES, + utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_COMPAT, allowed_values=[constants.VALUE_DEFAULT]) for param in opts.hvparams: diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 180657feb7ebaf3b8390d01ccfe50e0cf7d440f1..ebc34f4e2a6706007b51a201cb0b60f162a1604b 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3563,6 +3563,7 @@ class LUClusterSetParams(LogicalUnit): self.cluster = cluster = self.cfg.GetClusterInfo() # validate params changes if self.op.beparams: + objects.UpgradeBeParams(self.op.beparams) utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES) self.new_beparams = cluster.SimpleFillBE(self.op.beparams) @@ -6132,6 +6133,7 @@ class LUInstanceStartup(LogicalUnit): # extra beparams if self.op.beparams: # fill the beparams dict + objects.UpgradeBeParams(self.op.beparams) utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES) def ExpandNames(self): @@ -8979,6 +8981,7 @@ class LUInstanceCreate(LogicalUnit): for param, value in self.op.beparams.iteritems(): if value == constants.VALUE_AUTO: self.op.beparams[param] = default_beparams[param] + objects.UpgradeBeParams(self.op.beparams) utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES) self.be_full = cluster.SimpleFillBE(self.op.beparams) @@ -11281,6 +11284,7 @@ class LUInstanceSetParams(LogicalUnit): if self.op.beparams: i_bedict = _GetUpdatedParams(instance.beparams, self.op.beparams, use_none=True) + objects.UpgradeBeParams(i_bedict) utils.ForceDictType(i_bedict, constants.BES_PARAMETER_TYPES) be_new = cluster.SimpleFillBE(i_bedict) self.be_proposed = self.be_new = be_new # the new actual values diff --git a/lib/constants.py b/lib/constants.py index e65eef037cf3693fbf1cc4b258c1ebd1de140e08..ed050ab795f2fcc09dc40ec7c213e7ef43966f88 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -867,13 +867,17 @@ BE_VCPUS = "vcpus" BE_AUTO_BALANCE = "auto_balance" BES_PARAMETER_TYPES = { - BE_MEMORY: VTYPE_SIZE, BE_MAXMEM: VTYPE_SIZE, BE_MINMEM: VTYPE_SIZE, BE_VCPUS: VTYPE_INT, BE_AUTO_BALANCE: VTYPE_BOOL, } +BES_PARAMETER_COMPAT = { + BE_MEMORY: VTYPE_SIZE, + } +BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES) + BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys()) # Node parameter names @@ -1627,7 +1631,6 @@ HVC_GLOBALS = frozenset([ ]) BEC_DEFAULTS = { - BE_MEMORY: 128, BE_MINMEM: 128, BE_MAXMEM: 128, BE_VCPUS: 1, diff --git a/lib/objects.py b/lib/objects.py index c23068e40f1f7de9be85ad6a2ab7f40d30fbf491..0b7dd8443ba71160c0aa9ccb6f62eee6aa18a609 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -107,8 +107,7 @@ def UpgradeBeParams(target): memory = target[constants.BE_MEMORY] target[constants.BE_MAXMEM] = memory target[constants.BE_MINMEM] = memory - #FIXME(dynmem): delete old value - #del target[constants.BE_MEMORY] + del target[constants.BE_MEMORY] class ConfigObject(object):