From: Guido Trotter Date: Tue, 2 Dec 2008 10:54:03 +0000 (+0000) Subject: cluster init: don't discard the hypervisor X-Git-Tag: v2.0.0beta1~237 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/8f348e36f902a87342025d56fd80c4509ec7fa75 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 --- diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 53cb6a3..e763aa1 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -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