diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 0164539829aefb25c8e6ec2fb53958fee43cdf2c..29589dbe85431faaa8347d62bc81384f00f1878b 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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.