Commit e7b6183b authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

QA: Verify hypervisors, make available through functions



Some parts of QA should only be run with certain hypervisors (e.g.
testing instance HV parameters). To make that happen we always define
the cluster's hypervisors and provide a function to get the default
hypervisor.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent a19d8cd5
......@@ -94,10 +94,11 @@ def TestClusterInit(rapi_user, rapi_secret):
fh.close()
# Initialize cluster
cmd = ["gnt-cluster", "init"]
cmd.append("--primary-ip-version=%d" %
qa_config.get("primary_ip_version", 4))
cmd = [
"gnt-cluster", "init",
"--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4),
"--enabled-hypervisors=%s" % qa_config.GetEnabledHypervisors(),
]
for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count",
"nic-count"):
......@@ -115,10 +116,6 @@ def TestClusterInit(rapi_user, rapi_secret):
cmd.append("--bridge=%s" % bridge)
cmd.append("--master-netdev=%s" % bridge)
htype = qa_config.get("enabled-hypervisors", None)
if htype:
cmd.append("--enabled-hypervisors=%s" % htype)
cmd.append(qa_config.get("name"))
AssertCommand(cmd)
......
......@@ -25,6 +25,7 @@
import os
from ganeti import constants
from ganeti import utils
from ganeti import serializer
from ganeti import compat
......@@ -33,6 +34,7 @@ import qa_error
_INSTANCE_CHECK_KEY = "instance-check"
_ENABLED_HV_KEY = "enabled-hypervisors"
cfg = None
......@@ -67,6 +69,15 @@ def Validate():
raise qa_error.Error("Can't find instance check script '%s': %s" %
(check, err))
enabled_hv = frozenset(GetEnabledHypervisors())
if not enabled_hv:
raise qa_error.Error("No hypervisor is enabled")
difference = enabled_hv - constants.HYPER_TYPES
if difference:
raise qa_error.Error("Unknown hypervisor(s) enabled: %s" %
utils.CommaJoin(difference))
def get(name, default=None):
return cfg.get(name, default)
......@@ -154,6 +165,34 @@ def GetInstanceCheckScript():
return cfg.get(_INSTANCE_CHECK_KEY, None)
def GetEnabledHypervisors():
"""Returns list of enabled hypervisors.
@rtype: list
"""
try:
value = cfg[_ENABLED_HV_KEY]
except KeyError:
return [constants.DEFAULT_ENABLED_HYPERVISOR]
else:
if isinstance(value, basestring):
# The configuration key ("enabled-hypervisors") implies there can be
# multiple values. Multiple hypervisors are comma-separated on the
# command line option to "gnt-cluster init", so we need to handle them
# equally here.
return value.split(",")
else:
return value
def GetDefaultHypervisor():
"""Returns the default hypervisor to be used.
"""
return GetEnabledHypervisors()[0]
def GetInstanceNicMac(inst, default=None):
"""Returns MAC address for instance's network interface.
......
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