Commit 9c6f0b51 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Check if instances use disk templates that get disabled

When disk templates get disabled via 'gnt-cluster modify', so far
we did not check if any instances still use a disk template of that
type. This patch adds the necessariy check.
It also includes adding a map of disk templates to storage types
and reordering of storage types and disk templates in alphabetical order.
Signed-off-by: default avatarHelga Velroyen <>
Reviewed-by: default avatarGuido Trotter <>
parent 6414296b
......@@ -4408,9 +4408,7 @@ class LUClusterSetParams(LogicalUnit):
_CheckHVParams(self, node_list, hv_name, hv_params)
# FIXME: Regarding enabled_storage_types: If a method is removed
# which is actually currently used by an instance, should removing
# it be prevented?
if self.op.os_hvp:
# no need to check any newly-enabled hypervisors, since the
......@@ -4434,6 +4432,26 @@ class LUClusterSetParams(LogicalUnit):
" specified" % self.op.default_iallocator,
def _CheckDiskTypeConsistency(self):
"""Check whether the storage types that are going to be disabled
are still in use by some instances.
cluster = self.cfg.GetClusterInfo()
instances = self.cfg.GetAllInstancesInfo()
storage_types_to_remove = set(cluster.enabled_storage_types) \
- set(self.op.enabled_storage_types)
for instance in instances.itervalues():
storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
if storage_type in storage_types_to_remove:
raise errors.OpPrereqError("Cannot disable storage type '%s',"
" because instance '%s' is using disk"
" template '%s'." %
def Exec(self, feedback_fn):
"""Change the parameters of the cluster.
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