Revision 83a309f9

b/lib/cmdlib.py
4424 4424
          hv_class.CheckParameterSyntax(hv_params)
4425 4425
          _CheckHVParams(self, node_list, hv_name, hv_params)
4426 4426

  
4427
    self._CheckDiskTypeConsistency()
4427
    self._CheckDiskTemplateConsistency()
4428 4428

  
4429 4429
    if self.op.os_hvp:
4430 4430
      # no need to check any newly-enabled hypervisors, since the
......
4448 4448
                                   " specified" % self.op.default_iallocator,
4449 4449
                                   errors.ECODE_INVAL)
4450 4450

  
4451
  def _CheckDiskTypeConsistency(self):
4452
    """Check whether the storage types that are going to be disabled
4451
  def _CheckDiskTemplateConsistency(self):
4452
    """Check whether the disk templates that are going to be disabled
4453 4453
       are still in use by some instances.
4454 4454

  
4455 4455
    """
4456
    if self.op.enabled_storage_types:
4456
    if self.op.enabled_disk_templates:
4457 4457
      cluster = self.cfg.GetClusterInfo()
4458 4458
      instances = self.cfg.GetAllInstancesInfo()
4459 4459

  
4460
      storage_types_to_remove = set(cluster.enabled_storage_types) \
4461
        - set(self.op.enabled_storage_types)
4460
      disk_templates_to_remove = set(cluster.enabled_disk_templates) \
4461
        - set(self.op.enabled_disk_templates)
4462 4462
      for instance in instances.itervalues():
4463
        storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
4464
                         instance.disk_template]
4465
        if storage_type in storage_types_to_remove:
4466
          raise errors.OpPrereqError("Cannot disable storage type '%s',"
4467
                                     " because instance '%s' is using disk"
4468
                                     " template '%s'." %
4469
                                     (storage_type, instance.name,
4470
                                      instance.disk_template))
4463
        if instance.disk_template in disk_templates_to_remove:
4464
          raise errors.OpPrereqError("Cannot disable disk template '%s',"
4465
                                     " because instance '%s' is using it." %
4466
                                     (instance.disk_template, instance.name))
4471 4467

  
4472 4468
  def Exec(self, feedback_fn):
4473 4469
    """Change the parameters of the cluster.

Also available in: Unified diff