diff --git a/lib/bootstrap.py b/lib/bootstrap.py index d4e5a091e1904acb5bc20c659dad4ec27d8dc775..a94a9e5ff914def403a3be4ab72d554121b9c030 100644 --- a/lib/bootstrap.py +++ b/lib/bootstrap.py @@ -128,7 +128,7 @@ def InitCluster(cluster_name, mac_prefix, master_netdev, file_storage_dir, candidate_pool_size, secondary_ip=None, vg_name=None, beparams=None, nicparams=None, hvparams=None, enabled_hypervisors=None, - default_hypervisor=None, modify_etc_hosts=True): + modify_etc_hosts=True): """Initialise the cluster. @type candidate_pool_size: int @@ -252,7 +252,6 @@ def InitCluster(cluster_name, mac_prefix, cluster_name=clustername.name, file_storage_dir=file_storage_dir, enabled_hypervisors=enabled_hypervisors, - default_hypervisor=default_hypervisor, beparams={constants.PP_DEFAULT: beparams}, nicparams={constants.PP_DEFAULT: nicparams}, hvparams=hvparams, diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 493f5a19e9bca5d71a7194906d00cb6e6cd8dfe5..88d600d076a315e73f16e6089db978b4839bc572 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2627,7 +2627,7 @@ class LUQueryClusterInfo(NoHooksLU): "architecture": (platform.architecture()[0], platform.machine()), "name": cluster.cluster_name, "master": cluster.master_node, - "default_hypervisor": cluster.default_hypervisor, + "default_hypervisor": cluster.enabled_hypervisors[0], "enabled_hypervisors": cluster.enabled_hypervisors, "hvparams": dict([(hypervisor_name, cluster.hvparams[hypervisor_name]) for hypervisor_name in cluster.enabled_hypervisors]), diff --git a/lib/config.py b/lib/config.py index acdca2ea0580eee573d2a2151493dd72f78f7387..d7523635177fed59b1c0f7b0d6e455435a75255f 100644 --- a/lib/config.py +++ b/lib/config.py @@ -658,7 +658,7 @@ class ConfigWriter: """Get the hypervisor type for this cluster. """ - return self._config_data.cluster.default_hypervisor + return self._config_data.cluster.enabled_hypervisors[0] @locking.ssynchronized(_config_lock, shared=1) def GetHostKey(self): diff --git a/lib/objects.py b/lib/objects.py index 106b704aa09f5e27de6f2cb9cb8eca9b627c7858..9184112414b3dd532092dbbd912cd1f6b22a763d 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -811,6 +811,14 @@ class Cluster(TaggableObject): if self.default_bridge is not None: self.default_bridge = None + # default_hypervisor is just the first enabled one in 2.1 + if self.default_hypervisor is not None: + self.enabled_hypervisors = [self.default_hypervisor] + \ + [hvname for hvname in self.enabled_hypervisors + if hvname != self.default_hypervisor] + self.default_hypervisor = None + + def ToDict(self): """Custom function for cluster. diff --git a/man/gnt-cluster.sgml b/man/gnt-cluster.sgml index 220b3c90bfedd235dd519b30d075106143d25923..4c39cbd186195347ebbaa8bf9e8bc3028d4e4a1e 100644 --- a/man/gnt-cluster.sgml +++ b/man/gnt-cluster.sgml @@ -313,8 +313,9 @@ The <option>--enabled-hypervisors</option> option allows you to set the list of hypervisors that will be enabled for this cluster. Instance hypervisors can only be choosen from - the list of enabled hypervisors. Currently, the following - hypervisors are available: + the list of enabled hypervisors, and the first entry of this list + will be used by default. Currently, the following hypervisors are + available: </para> <para> @@ -360,13 +361,6 @@ specified, only the xen-pvm hypervisor is enabled by default. </para> - <para> - With the <option>-t</option> option, the default hypervisor - can be set. It has to be a member of the list of enabled - hypervisors. If not specified, the first entry on the list of - enabled hypervisors will be used by default. - </para> - <para> The <option>--backend-parameters</option> option allows you to set the default backend parameters for the cluster. The parameter diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 66c9c65ebec9a66fcb897fe1ef03af608059a9ee..b41a380c27e21b6937294bc5aedf39dfa89c8968 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -58,17 +58,7 @@ def InitCluster(opts, args): vg_name = constants.DEFAULT_VG hvlist = opts.enabled_hypervisors - if hvlist is not None: - hvlist = hvlist.split(",") - else: - hvlist = [opts.default_hypervisor] - - # avoid an impossible situation - 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 + hvlist = hvlist.split(",") hvparams = dict(opts.hvparams) beparams = opts.beparams @@ -101,7 +91,6 @@ def InitCluster(opts, args): master_netdev=opts.master_netdev, file_storage_dir=opts.file_storage_dir, enabled_hypervisors=hvlist, - default_hypervisor=opts.default_hypervisor, hvparams=hvparams, beparams=beparams, nicparams=nicparams, @@ -578,11 +567,7 @@ commands = { action="store_false", default=True,), make_option("--enabled-hypervisors", dest="enabled_hypervisors", help="Comma-separated list of hypervisors", - type="string", default=None), - make_option("-t", "--default-hypervisor", - dest="default_hypervisor", - help="Default hypervisor to use for instance creation", - choices=list(constants.HYPER_TYPES), + type="string", default=constants.DEFAULT_ENABLED_HYPERVISOR), ikv_option("-H", "--hypervisor-parameters", dest="hvparams", help="Hypervisor and hypervisor options, in the" diff --git a/test/ganeti.config_unittest.py b/test/ganeti.config_unittest.py index 9287fc3d0554eaf952cfb3d055870239e0c04031..64210d9bb8049f53fcc3f38d3bf6d8a610ccf5d4 100755 --- a/test/ganeti.config_unittest.py +++ b/test/ganeti.config_unittest.py @@ -68,7 +68,7 @@ class TestConfigRunner(unittest.TestCase): volume_group_name="xenvg", nicparams={constants.PP_DEFAULT: constants.NICC_DEFAULTS}, tcpudp_port_pool=set(), - default_hypervisor=constants.HT_FAKE, + enabled_hypervisors=[constants.HT_FAKE], master_node=me.name, master_ip="127.0.0.1", master_netdev=constants.DEFAULT_BRIDGE,