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
if hvlist is not None:
hvlist = hvlist.split(",")
else:
if hvlist is not None:
hvlist = hvlist.split(",")
else:
- hvlist = [constants.DEFAULT_ENABLED_HYPERVISOR]
+ hvlist = [opts.default_hypervisor]
# avoid an impossible situation
# 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:
hvparams = opts.hvparams
if hvparams:
master_netdev=opts.master_netdev,
file_storage_dir=opts.file_storage_dir,
enabled_hypervisors=hvlist,
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
hvparams=hvparams,
beparams=beparams)
return 0