Revision 41044e04 lib/cmdlib.py

b/lib/cmdlib.py
828 828
    if (not value or value == [constants.VALUE_DEFAULT] or
829 829
        value == constants.VALUE_DEFAULT):
830 830
      if group_policy:
831
        del ipolicy[key]
831
        if key in ipolicy:
832
          del ipolicy[key]
832 833
      else:
833 834
        raise errors.OpPrereqError("Can't unset ipolicy attribute '%s'"
834 835
                                   " on the cluster'" % key,
......
843 844
                                     " '%s': '%s', error: %s" %
844 845
                                     (key, value, err), errors.ECODE_INVAL)
845 846
      elif key == constants.ISPECS_MINMAX:
846
        for k in value.keys():
847
          utils.ForceDictType(value[k], constants.ISPECS_PARAMETER_TYPES)
847
        for minmax in value:
848
          for k in minmax.keys():
849
            utils.ForceDictType(minmax[k], constants.ISPECS_PARAMETER_TYPES)
848 850
        ipolicy[key] = value
849 851
      elif key == constants.ISPECS_STD:
850 852
        if group_policy:
......
1276 1278
    ret.append("Disk template %s is not allowed (allowed templates: %s)" %
1277 1279
               (disk_template, utils.CommaJoin(allowed_dts)))
1278 1280

  
1279
  minmax = ipolicy[constants.ISPECS_MINMAX]
1280
  return ret + filter(None,
1281
                      (_compute_fn(name, qualifier, minmax, value)
1282
                       for (name, qualifier, value) in test_settings))
1281
  min_errs = None
1282
  for minmax in ipolicy[constants.ISPECS_MINMAX]:
1283
    errs = filter(None,
1284
                  (_compute_fn(name, qualifier, minmax, value)
1285
                   for (name, qualifier, value) in test_settings))
1286
    if min_errs is None or len(errs) < len(min_errs):
1287
      min_errs = errs
1288
  assert min_errs is not None
1289
  return ret + min_errs
1283 1290

  
1284 1291

  
1285 1292
def _ComputeIPolicyInstanceViolation(ipolicy, instance, cfg,

Also available in: Unified diff