return "/sys/block/%s/device/state" % disk
-def _GetInstanceInfo(instance):
+def GetInstanceInfo(instance):
"""Return information about the actual state of an instance.
@type instance: string
disk_template = info["Disk template"]
if not disk_template:
raise qa_error.Error("Can't get instance disk template")
- storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[disk_template]
+ storage_type = constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[disk_template]
re_drbdnode = re.compile(r"^([^\s,]+),\s+minor=([0-9]+)$")
vols = []
drbd_min = {}
for (count, diskinfo) in enumerate(info["Disks"]):
(dtype, _) = diskinfo["disk/%s" % count].split(",", 1)
- if dtype == constants.LD_DRBD8:
+ if dtype == constants.DT_DRBD8:
for child in diskinfo["child devices"]:
vols.append(child["logical_id"])
for key in ["nodeA", "nodeB"]:
minor = int(m.group(2))
minorlist = drbd_min.setdefault(node, [])
minorlist.append(minor)
- elif dtype == constants.LD_LV:
+ elif dtype == constants.DT_PLAIN:
vols.append(diskinfo["logical_id"])
assert nodes
@param instance: the instance
"""
- info = _GetInstanceInfo(instance.name)
+ info = GetInstanceInfo(instance.name)
# FIXME: destruction/removal should be part of the disk class
if info["storage-type"] == constants.ST_LVM_VG:
vols = info["volumes"]
for node in info["nodes"]:
AssertCommand(["lvremove", "-f"] + vols, node=node)
elif info["storage-type"] == constants.ST_FILE:
- # FIXME: file storage dir not configurable in qa
# Note that this works for both file and sharedfile, and this is intended.
- filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
- idir = os.path.join(filestorage, instance.name)
+ storage_dir = qa_config.get("file-storage-dir",
+ pathutils.DEFAULT_FILE_STORAGE_DIR)
+ idir = os.path.join(storage_dir, instance.name)
for node in info["nodes"]:
AssertCommand(["rm", "-rf", idir], node=node)
elif info["storage-type"] == constants.ST_DISKLESS:
@InstanceCheck(None, INST_UP, RETURN_VALUE)
+def TestInstanceAddSharedFile(nodes):
+ """gnt-instance add -t sharedfile"""
+ assert len(nodes) == 1
+ if constants.DT_SHARED_FILE in qa_config.GetEnabledDiskTemplates():
+ return CreateInstanceByDiskTemplateOneNode(nodes, constants.DT_SHARED_FILE)
+
+
+@InstanceCheck(None, INST_UP, RETURN_VALUE)
def TestInstanceAddDiskless(nodes):
"""gnt-instance add -t diskless"""
assert len(nodes) == 1
finally:
qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
- info = _GetInstanceInfo(rename_source)
+ info = GetInstanceInfo(rename_source)
# Check instance volume tags correctly updated. Note that this check is lvm
# specific, so we skip it for non-lvm-based instances.
current = currentnode.primary
other = othernode.primary
- # FIXME: the qa doesn't have a customizable file storage dir parameter. As
- # such for now we use the default.
- filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
+ filestorage = qa_config.get("file-storage-dir",
+ pathutils.DEFAULT_FILE_STORAGE_DIR)
disk = os.path.join(filestorage, name)
AssertCommand(["gnt-instance", "modify", "--new-primary=%s" % other, name],
def TestInstanceExport(instance, node):
"""gnt-backup export -n ..."""
name = instance.name
+ # Export does not work for file-based templates, thus we skip the test
+ if instance.disk_template in [constants.DT_FILE, constants.DT_SHARED_FILE]:
+ return
AssertCommand(["gnt-backup", "export", "-n", node.primary, name])
return qa_utils.ResolveInstanceName(name)
def TestInstanceImport(newinst, node, expnode, name):
"""gnt-backup import"""
templ = constants.DT_PLAIN
+ if not qa_config.IsTemplateSupported(templ):
+ return
cmd = (["gnt-backup", "import",
"--disk-template=%s" % templ,
"--no-ip-check",
@param set_online: function to call to set the node on-line
"""
- info = _GetInstanceInfo(instance.name)
+ info = GetInstanceInfo(instance.name)
set_offline(snode)
try:
TestInstanceRemove(instance)
# syntax), we always have to perform both commands and ignore the
# output.
drbd_shutdown_cmd = \
- "(drbdsetup %d down && drbdsetup down resource%d) || /bin/true" % \
+ "(drbdsetup %d down >/dev/null 2>&1;" \
+ " drbdsetup down resource%d >/dev/null 2>&1) || /bin/true" % \
(minor, minor)
AssertCommand(drbd_shutdown_cmd, node=snode)
AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode)
elif info["storage-type"] == constants.ST_FILE:
- filestorage = pathutils.DEFAULT_FILE_STORAGE_DIR
+ filestorage = qa_config.get("file-storage-dir",
+ pathutils.DEFAULT_FILE_STORAGE_DIR)
disk = os.path.join(filestorage, instance.name)
AssertCommand(["rm", "-rf", disk], node=snode)
def TestInstanceCreationRestrictedByDiskTemplates():
"""Test adding instances for disabled disk templates."""
+ if qa_config.TestEnabled("cluster-exclusive-storage"):
+ # These tests are valid only for non-exclusive storage
+ return
+
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
nodes = qa_config.AcquireManyNodes(2)
# Setup the cluster with the enabled_disk_templates
AssertCommand(
["gnt-cluster", "modify",
- "--enabled-disk-template=%s" %
- ",".join(enabled_disk_templates)],
+ "--enabled-disk-templates=%s" % ",".join(enabled_disk_templates),
+ "--ipolicy-disk-templates=%s" % ",".join(enabled_disk_templates)],
fail=False)
# Test instance creation for enabled disk templates
for (enabled, disabled) in [(templates1, templates2),
(templates2, templates1)]:
AssertCommand(["gnt-cluster", "modify",
- "--enabled-disk-template=%s" %
- ",".join(enabled)],
+ "--enabled-disk-templates=%s" % ",".join(enabled),
+ "--ipolicy-disk-templates=%s" % ",".join(enabled)],
fail=False)
for disk_template in disabled:
CreateInstanceByDiskTemplate(nodes, disk_template, fail=True)
set([constants.DT_DISKLESS, constants.DT_BLOCK]) -
set(enabled_disk_templates))
AssertCommand(["gnt-cluster", "modify",
- "--enabled-disk-template=%s" %
+ "--enabled-disk-templates=%s" %
+ ",".join(other_disk_templates),
+ "--ipolicy-disk-templates=%s" %
",".join(other_disk_templates)],
fail=False)
CreateInstanceByDiskTemplate(nodes, enabled_disk_templates[0], fail=True)
# Restore initially enabled disk templates
AssertCommand(["gnt-cluster", "modify",
- "--enabled-disk-template=%s" %
+ "--enabled-disk-templates=%s" %
+ ",".join(enabled_disk_templates),
+ "--ipolicy-disk-templates=%s" %
",".join(enabled_disk_templates)],
fail=False)