Commit 615551b2 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Rename disk_template/storage_type map + cleanup



This patch renames the mapping of disk templates to storage
types to MAP_DISK_TEMPLATE_STORAGE_TYPE, which is a more
expressive name since it indicates that it is a mapping and
does not have the inconsistent usage of singular and plural
anymore.

Additionally, this patch sorts the disk templates
alphabetically in the constants file.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent f79be8ec
......@@ -457,14 +457,14 @@ DT_SHARED_FILE = "sharedfile"
# This only happens on an upgrade from a version of Ganeti that did not
# support the 'enabled_disk_templates' so far.
DISK_TEMPLATE_PREFERENCE = [
DT_BLOCK,
DT_DISKLESS,
DT_DRBD8,
DT_PLAIN,
DT_EXT,
DT_FILE,
DT_SHARED_FILE,
DT_PLAIN,
DT_RBD,
DT_BLOCK,
DT_DISKLESS,
DT_EXT
DT_SHARED_FILE,
]
DISK_TEMPLATES = compat.UniqueFrozenset([
......@@ -485,7 +485,7 @@ DEFAULT_ENABLED_DISK_TEMPLATES = [
]
# mapping of disk templates to storage types
DISK_TEMPLATES_STORAGE_TYPE = {
MAP_DISK_TEMPLATE_STORAGE_TYPE = {
DT_BLOCK: ST_BLOCK,
DT_DISKLESS: ST_DISKLESS,
DT_DRBD8: ST_LVM_VG,
......
......@@ -32,7 +32,7 @@ def GetDiskTemplatesOfStorageType(storage_type):
"""Given the storage type, returns a list of disk templates based on that
storage type."""
return [dt for dt in constants.DISK_TEMPLATES
if constants.DISK_TEMPLATES_STORAGE_TYPE[dt] == storage_type]
if constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[dt] == storage_type]
def GetLvmDiskTemplates():
......@@ -91,7 +91,7 @@ def _GetDefaultStorageUnitForDiskTemplate(cfg, disk_template):
storage
"""
storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[disk_template]
storage_type = constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[disk_template]
cluster = cfg.GetClusterInfo()
if disk_template in GetLvmDiskTemplates():
return (storage_type, cfg.GetVGName())
......
......@@ -380,8 +380,9 @@ class _QaConfig(object):
"""
enabled_disk_templates = self.GetEnabledDiskTemplates()
enabled_storage_types = list(set([constants.DISK_TEMPLATES_STORAGE_TYPE[dt]
for dt in enabled_disk_templates]))
enabled_storage_types = list(
set([constants.MAP_DISK_TEMPLATE_STORAGE_TYPE[dt]
for dt in enabled_disk_templates]))
# Storage type 'lvm-pv' cannot be activated via a disk template,
# therefore we add it if 'lvm-vg' is present.
if constants.ST_LVM_VG in enabled_storage_types:
......
......@@ -88,7 +88,7 @@ def GetInstanceInfo(instance):
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 = []
......
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