Commit c66d8987 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Upgrade configuration wrt enabled storage types



This implements an online update of the configuration for when a configuration
is loaded that does not yet contain the 'enabled_storage_types' attribute.
Note that this will require more changes as dis/enabling of (shared) file
storage at configure time will be removed.
This patch includes adding a mapping from disk templates to storage types. While
I was on it, I also reordered the disk template and storage type parameters
alphabetically, to make dealing with those easier.
Also, this mentions the configuration change in the NEWS file.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent dacd8ba4
......@@ -11,6 +11,13 @@ Version 2.8.0 beta1
- The :doc:`Remote API <rapi>` daemon now supports a command line flag
to always require authentication, ``--require-authentication``. It can
be specified in ``$sysconfdir/default/ganeti``.
- A new cluster attribute 'enabled_storage_types' is introduced. It will
be used to manage the storage types to be used by instances in the cluster.
Initially, it will be set to a list that includes lvm, file and sharedfile
if those are enabled. Additionally, it will include all storage types that
are currently used by instances. The order of storage types will be based
on Ganeti's history of supporting them. In the future, the first entry of
the list will be used as a default storage type on instance creation.
Version 2.7.0 beta1
......
......@@ -373,24 +373,24 @@ HKR_FAIL = 1
HKR_SUCCESS = 2
# Storage types
ST_BLOCK = "blockdev"
ST_DISKLESS = "diskless"
ST_EXT = "ext"
ST_FILE = "file"
ST_LVM_PV = "lvm-pv"
ST_LVM_VG = "lvm-vg"
ST_DISKLESS = "diskless"
ST_SHARED_FILE = "sharedfile"
ST_BLOCK = "blockdev"
ST_RADOS = "rados"
ST_EXT = "ext"
ST_SHARED_FILE = "sharedfile"
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
ST_BLOCK,
ST_DISKLESS,
ST_EXT,
ST_FILE,
ST_LVM_PV,
ST_LVM_VG,
ST_DISKLESS,
ST_SHARED_FILE,
ST_BLOCK,
ST_RADOS,
ST_EXT,
ST_SHARED_FILE,
])
# Per default, only lvm is enabled.
......@@ -398,6 +398,18 @@ DEFAULT_ENABLED_STORAGE_TYPES = compat.UniqueFrozenset([
ST_LVM_VG,
])
# This is used to order determine the default storage type when the list
# of enabled storage types is inferred from the current state of the cluster.
# This only happens on an upgrade from a version of Ganeti that did not
# support the 'enabled_storage_methods' so far.
STORAGE_TYPES_PREFERENCE = [
ST_LVM_VG,
ST_FILE,
ST_SHARED_FILE,
ST_RADOS,
ST_BLOCK,
]
# Storage fields
# first two are valid in LU context only, not passed to backend
SF_NODE = "node"
......@@ -437,14 +449,26 @@ VALID_STORAGE_OPERATIONS = {
LDS_FAULTY) = range(1, 4)
# disk template types
DT_BLOCK = "blockdev"
DT_DISKLESS = "diskless"
DT_PLAIN = "plain"
DT_DRBD8 = "drbd"
DT_EXT = "ext"
DT_FILE = "file"
DT_SHARED_FILE = "sharedfile"
DT_BLOCK = "blockdev"
DT_PLAIN = "plain"
DT_RBD = "rbd"
DT_EXT = "ext"
DT_SHARED_FILE = "sharedfile"
# mapping of disk templates to storage types
DISK_TEMPLATES_STORAGE_TYPE = {
DT_BLOCK: ST_BLOCK,
DT_DISKLESS: ST_DISKLESS,
DT_DRBD8: ST_LVM_VG,
DT_EXT: ST_EXT,
DT_FILE: ST_FILE,
DT_PLAIN: ST_LVM_VG,
DT_RBD: ST_RADOS,
DT_SHARED_FILE: ST_SHARED_FILE,
}
# the set of network-mirrored disk templates
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
......
......@@ -463,6 +463,37 @@ class ConfigData(ConfigObject):
self.networks = {}
for network in self.networks.values():
network.UpgradeConfig()
self._UpgradeStorageTypes()
def _UpgradeStorageTypes(self):
"""Upgrade the cluster's enabled storage types by inspecting the currently
enabled and/or used storage types.
"""
# enabled_storage_types in the cluster config were introduced in 2.8. Remove
# this code once upgrading from earlier versions is deprecated.
if not self.cluster.enabled_storage_types:
storage_type_set = \
set([constants.DISK_TEMPLATES_STORAGE_TYPE[inst.disk_template]
for inst in self.instances.values()])
# Add lvm, file and shared file storage, if they are enabled, even though
# they might currently not be used.
if self.cluster.volume_group_name:
storage_type_set.add(constants.ST_LVM_VG)
# FIXME: Adapt this when dis/enabling at configure time is removed.
if constants.ENABLE_FILE_STORAGE:
storage_type_set.add(constants.ST_FILE)
if constants.ENABLE_SHARED_FILE_STORAGE:
storage_type_set.add(constants.ST_SHARED_FILE)
# Set enabled_storage_types to the inferred storage types. Order them
# according to a preference list that is based on Ganeti's history of
# supported storage types.
self.cluster.enabled_storage_types = []
for preferred_type in constants.STORAGE_TYPES_PREFERENCE:
if preferred_type in storage_type_set:
self.cluster.enabled_storage_types.append(preferred_type)
storage_type_set.remove(preferred_type)
self.cluster.enabled_storage_types.extend(list(storage_type_set))
class NIC(ConfigObject):
......
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