Commit 8f348e36 authored by Guido Trotter's avatar Guido Trotter
Browse files

cluster init: don't discard the hypervisor

On cluster init if the user specifies a default hypervisor (with -t)
which is not in the default list of enabled hypervisors (currently just
xen-pvm) without explicitely specifying the list we silently override
the choice.

With this patch we set the list by default to just the required one, and
we bail out should the list be hand-specified and not contain the
default one. This still has an issue when the user doesn't specify a
default hypervisor but specifies a list which doesn't include xen-pvm:
in this case though we give an error, rather than silently discarding
choices.

Reviewed-by: imsnah
parent d4b72030
......@@ -60,13 +60,14 @@ def InitCluster(opts, args):
if hvlist is not None:
hvlist = hvlist.split(",")
else:
hvlist = [constants.DEFAULT_ENABLED_HYPERVISOR]
hvlist = [opts.default_hypervisor]
# avoid an impossible situation
if opts.default_hypervisor in hvlist:
default_hypervisor = opts.default_hypervisor
else:
default_hypervisor = hvlist[0]
if opts.default_hypervisor not in hvlist:
ToStderr("The default hypervisor requested (%s) is not"
" within the enabled hypervisor list (%s)" %
(opts.default_hypervisor, hvlist))
return 1
hvparams = opts.hvparams
if hvparams:
......@@ -120,7 +121,7 @@ def InitCluster(opts, args):
master_netdev=opts.master_netdev,
file_storage_dir=opts.file_storage_dir,
enabled_hypervisors=hvlist,
default_hypervisor=default_hypervisor,
default_hypervisor=opts.default_hypervisor,
hvparams=hvparams,
beparams=beparams)
return 0
......
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