Commit b119bccb authored by Guido Trotter's avatar Guido Trotter

Make sure enabled_hypervisors list is valid

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e52019f7
......@@ -137,6 +137,14 @@ def InitCluster(cluster_name, mac_prefix, def_bridge,
if config.ConfigWriter.IsCluster():
raise errors.OpPrereqError("Cluster is already initialised")
if not enabled_hypervisors:
raise errors.OpPrereqError("Enabled hypervisors list must contain at"
" least one member")
invalid_hvs = set(enabled_hypervisors) - constants.HYPER_TYPES
if invalid_hvs:
raise errors.OpPrereqError("Enabled hypervisors contains invalid"
" entries: %s" % invalid_hvs)
hostname = utils.HostInfo()
if hostname.ip.startswith("127."):
......
......@@ -1516,6 +1516,13 @@ class LUSetClusterParams(LogicalUnit):
if self.op.enabled_hypervisors is not None:
self.hv_list = self.op.enabled_hypervisors
if not self.hv_list:
raise errors.OpPrereqError("Enabled hypervisors list must contain at"
" least one member")
invalid_hvs = set(self.hv_list) - constants.HYPER_TYPES
if invalid_hvs:
raise errors.OpPrereqError("Enabled hypervisors contains invalid"
" entries: %s" % invalid_hvs)
else:
self.hv_list = cluster.enabled_hypervisors
......
......@@ -93,11 +93,6 @@ def InitCluster(opts, args):
hvparams[hv][parameter] = constants.HVC_DEFAULTS[hv][parameter]
utils.ForceDictType(hvparams[hv], constants.HVS_PARAMETER_TYPES)
for hv in hvlist:
if hv not in constants.HYPER_TYPES:
ToStderr("invalid hypervisor: %s", hv)
return 1
bootstrap.InitCluster(cluster_name=args[0],
secondary_ip=opts.secondary_ip,
vg_name=vg_name,
......
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