Revision 9d276e93 lib/cmdlib/common.py

b/lib/cmdlib/common.py
1086 1086
                               (disk_template,
1087 1087
                                ",".join(cluster.enabled_disk_templates)))
1088 1088

  
1089

  
1090
def CheckStorageTypeEnabled(cluster, storage_type):
1091
  """Helper function to check if a storage type is enabled.
1092

  
1093
  @type cluster: C{objects.Cluster}
1094
  @param cluster: the cluster's configuration
1095
  @type storage_type: str
1096
  @param storage_type: the storage type to be checked
1097

  
1098
  """
1099
  assert storage_type is not None
1100
  assert storage_type in constants.VALID_STORAGE_TYPES
1101
  # special case for lvm-pv, because it cannot be enabled
1102
  # via disk templates
1103
  if storage_type == constants.ST_LVM_PV:
1104
    CheckStorageTypeEnabled(cluster, constants.ST_LVM_VG)
1105
  else:
1106
    possible_disk_templates = \
1107
        utils.storage.GetDiskTemplatesOfStorageType(storage_type)
1108
    for disk_template in possible_disk_templates:
1109
      if disk_template in cluster.enabled_disk_templates:
1110
        return
1111
    raise errors.OpPrereqError("No disk template of storage type '%s' is"
1112
                               " enabled in this cluster. Enabled disk"
1113
                               " templates are: %s" % (storage_type,
1114
                               ",".join(cluster.enabled_disk_templates)))

Also available in: Unified diff