Commit 83a309f9 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

gnt-cluster modify: verify instance's disk template usage



Adds a verification step to 'gnt-cluster modify' to make sure that no
disk template is disabled that is currently in use by at least one instance.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtarara@google.com>
parent 66af5ec5
......@@ -4424,7 +4424,7 @@ class LUClusterSetParams(LogicalUnit):
hv_class.CheckParameterSyntax(hv_params)
_CheckHVParams(self, node_list, hv_name, hv_params)
 
self._CheckDiskTypeConsistency()
self._CheckDiskTemplateConsistency()
 
if self.op.os_hvp:
# no need to check any newly-enabled hypervisors, since the
......@@ -4448,26 +4448,22 @@ class LUClusterSetParams(LogicalUnit):
" specified" % self.op.default_iallocator,
errors.ECODE_INVAL)
 
def _CheckDiskTypeConsistency(self):
"""Check whether the storage types that are going to be disabled
def _CheckDiskTemplateConsistency(self):
"""Check whether the disk templates that are going to be disabled
are still in use by some instances.
 
"""
if self.op.enabled_storage_types:
if self.op.enabled_disk_templates:
cluster = self.cfg.GetClusterInfo()
instances = self.cfg.GetAllInstancesInfo()
 
storage_types_to_remove = set(cluster.enabled_storage_types) \
- set(self.op.enabled_storage_types)
disk_templates_to_remove = set(cluster.enabled_disk_templates) \
- set(self.op.enabled_disk_templates)
for instance in instances.itervalues():
storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
instance.disk_template]
if storage_type in storage_types_to_remove:
raise errors.OpPrereqError("Cannot disable storage type '%s',"
" because instance '%s' is using disk"
" template '%s'." %
(storage_type, instance.name,
instance.disk_template))
if instance.disk_template in disk_templates_to_remove:
raise errors.OpPrereqError("Cannot disable disk template '%s',"
" because instance '%s' is using it." %
(instance.disk_template, instance.name))
 
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