Revision 9c6f0b51

b/lib/cmdlib.py
4408 4408
          hv_class.CheckParameterSyntax(hv_params)
4409 4409
          _CheckHVParams(self, node_list, hv_name, hv_params)
4410 4410

  
4411
    # FIXME: Regarding enabled_storage_types: If a method is removed
4412
    # which is actually currently used by an instance, should removing
4413
    # it be prevented?
4411
    self._CheckDiskTypeConsistency()
4414 4412

  
4415 4413
    if self.op.os_hvp:
4416 4414
      # no need to check any newly-enabled hypervisors, since the
......
4434 4432
                                   " specified" % self.op.default_iallocator,
4435 4433
                                   errors.ECODE_INVAL)
4436 4434

  
4435
  def _CheckDiskTypeConsistency(self):
4436
    """Check whether the storage types that are going to be disabled
4437
       are still in use by some instances.
4438

  
4439
    """
4440
    cluster = self.cfg.GetClusterInfo()
4441
    instances = self.cfg.GetAllInstancesInfo()
4442

  
4443
    storage_types_to_remove = set(cluster.enabled_storage_types) \
4444
      - set(self.op.enabled_storage_types)
4445
    for instance in instances.itervalues():
4446
      storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[
4447
                       instance.disk_template]
4448
      if storage_type in storage_types_to_remove:
4449
        raise errors.OpPrereqError("Cannot disable storage type '%s',"
4450
                                   " because instance '%s' is using disk"
4451
                                   " template '%s'." %
4452
                                   (storage_type, instance.name,
4453
                                    instance.disk_template))
4454

  
4437 4455
  def Exec(self, feedback_fn):
4438 4456
    """Change the parameters of the cluster.
4439 4457

  

Also available in: Unified diff