Commit b2e233a5 authored by Guido Trotter's avatar Guido Trotter

Remove BE_MEMORY from beparams but keep compatibility

Queries are already compatible (be/memory is an alias for be/maxmem) and
import/exports work. This patch patch fixes it for cluster init, modify
and instance add/start/modify.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 37036867
......@@ -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)
......
......@@ -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:
......
......@@ -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)
......
......@@ -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:
......
......@@ -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
......
......@@ -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,
......
......@@ -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):
......
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