Revision 4e771a95 lib/cmdlib/common.py

b/lib/cmdlib/common.py
1116 1116
                               " enabled in this cluster. Enabled disk"
1117 1117
                               " templates are: %s" % (storage_type,
1118 1118
                               ",".join(cluster.enabled_disk_templates)))
1119

  
1120

  
1121
def CheckIpolicyVsDiskTemplates(ipolicy, enabled_disk_templates):
1122
  """Checks ipolicy disk templates against enabled disk tempaltes.
1123

  
1124
  @type ipolicy: dict
1125
  @param ipolicy: the new ipolicy
1126
  @type enabled_disk_templates: list of string
1127
  @param enabled_disk_templates: list of enabled disk templates on the
1128
    cluster
1129
  @raises errors.OpPrereqError: if there is at least one allowed disk
1130
    template that is not also enabled.
1131

  
1132
  """
1133
  assert constants.IPOLICY_DTS in ipolicy
1134
  allowed_disk_templates = ipolicy[constants.IPOLICY_DTS]
1135
  not_enabled = set(allowed_disk_templates) - set(enabled_disk_templates)
1136
  if not_enabled:
1137
    raise errors.OpPrereqError("The following disk template are allowed"
1138
                               " by the ipolicy, but not enabled on the"
1139
                               " cluster: %s" % utils.CommaJoin(not_enabled))

Also available in: Unified diff