Commit e4a4391d authored by René Nussbaumer's avatar René Nussbaumer

Verify the options on diskparameters

This prevents from setting for example drbd options on the plain disk
template.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 32be86da
......@@ -463,6 +463,11 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
" %s" % (template,
utils.CommaJoin(unknown_params)))
utils.ForceDictType(dt_params, constants.DISK_DT_TYPES)
try:
utils.VerifyDictOptions(diskparams, constants.DISK_DT_DEFAULTS)
except errors.OpPrereqError, err:
raise errors.OpPrereqError("While verify diskparam options: %s" % err,
errors.ECODE_INVAL)
# set up ssh config and /etc/hosts
sshline = utils.ReadFile(constants.SSH_HOST_RSA_PUB)
......
......@@ -3856,6 +3856,11 @@ class LUClusterSetParams(LogicalUnit):
if self.op.diskparams:
for dt_params in self.op.diskparams.values():
utils.ForceDictType(dt_params, constants.DISK_DT_TYPES)
try:
utils.VerifyDictOptions(self.op.diskparams, constants.DISK_DT_DEFAULTS)
except errors.OpPrereqError, err:
raise errors.OpPrereqError("While verify diskparams options: %s" % err,
errors.ECODE_INVAL)
def ExpandNames(self):
# FIXME: in the future maybe other cluster params won't require checking on
......@@ -13607,6 +13612,11 @@ class LUGroupAdd(LogicalUnit):
utils.ForceDictType(self.op.diskparams[templ],
constants.DISK_DT_TYPES)
self.new_diskparams = self.op.diskparams
try:
utils.VerifyDictOptions(self.new_diskparams, constants.DISK_DT_DEFAULTS)
except errors.OpPrereqError, err:
raise errors.OpPrereqError("While verify diskparams options: %s" % err,
errors.ECODE_INVAL)
else:
self.new_diskparams = {}
......@@ -13968,6 +13978,11 @@ class LUGroupSetParams(LogicalUnit):
# As we've all subdicts of diskparams ready, lets merge the actual
# dict with all updated subdicts
self.new_diskparams = objects.FillDict(diskparams, new_diskparams)
try:
utils.VerifyDictOptions(self.new_diskparams, constants.DISK_DT_DEFAULTS)
except errors.OpPrereqError, err:
raise errors.OpPrereqError("While verify diskparams options: %s" % err,
errors.ECODE_INVAL)
if self.op.hv_state:
self.new_hv_state = _MergeAndVerifyHvState(self.op.hv_state,
......
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