Revision 0e68bf27 lib/cmdlib.py

b/lib/cmdlib.py
1016 1016
                                 (instance.name, msg), errors.ECODE_STATE)
1017 1017

  
1018 1018

  
1019
def _CheckMinMaxSpecs(name, ipolicy, value):
1020
  """Checks if value is in the desired range.
1019
def _ComputeMinMaxSpec(name, ipolicy, value):
1020
  """Computes if value is in the desired range.
1021 1021

  
1022 1022
  @param name: name of the parameter for which we perform the check
1023 1023
  @param ipolicy: dictionary containing min, max and std values
......
1038 1038

  
1039 1039
def _ComputeIPolicySpecViolation(ipolicy, mem_size, cpu_count, disk_count,
1040 1040
                                 nic_count, disk_sizes,
1041
                                 _check_spec_fn=_CheckMinMaxSpecs):
1041
                                 _compute_fn=_ComputeMinMaxSpec):
1042 1042
  """Verifies ipolicy against provided specs.
1043 1043

  
1044 1044
  @type ipolicy: dict
......
1053 1053
  @param nic_count: Number of nics used
1054 1054
  @type disk_sizes: list of ints
1055 1055
  @param disk_sizes: Disk sizes of used disk (len must match C{disk_count})
1056
  @param _check_spec_fn: The checking function (unittest only)
1056
  @param _compute_fn: The compute function (unittest only)
1057 1057
  @return: A list of violations, or an empty list of no violations are found
1058 1058

  
1059 1059
  """
......
1067 1067
    ] + map((lambda d: (constants.ISPEC_DISK_SIZE, d)), disk_sizes)
1068 1068

  
1069 1069
  return filter(None,
1070
                (_check_spec_fn(name, ipolicy, value)
1070
                (_compute_fn(name, ipolicy, value)
1071 1071
                 for (name, value) in test_settings))
1072 1072

  
1073 1073

  

Also available in: Unified diff