Revision 8b057218 lib/objects.py

b/lib/objects.py
946 946

  
947 947
  """
948 948
  @classmethod
949
  def CheckParameterSyntax(cls, ipolicy):
949
  def CheckParameterSyntax(cls, ipolicy, check_std):
950 950
    """ Check the instance policy for validity.
951 951

  
952 952
    """
953 953
    for param in constants.ISPECS_PARAMETERS:
954
      InstancePolicy.CheckISpecSyntax(ipolicy, param)
954
      InstancePolicy.CheckISpecSyntax(ipolicy, param, check_std)
955 955
    if constants.IPOLICY_DTS in ipolicy:
956 956
      InstancePolicy.CheckDiskTemplates(ipolicy[constants.IPOLICY_DTS])
957 957
    for key in constants.IPOLICY_PARAMETERS:
......
963 963
                                      utils.CommaJoin(wrong_keys))
964 964

  
965 965
  @classmethod
966
  def CheckISpecSyntax(cls, ipolicy, name):
966
  def CheckISpecSyntax(cls, ipolicy, name, check_std):
967 967
    """Check the instance policy for validity on a given key.
968 968

  
969 969
    We check if the instance policy makes sense for a given key, that is
......
973 973
    @param ipolicy: dictionary with min, max, std specs
974 974
    @type name: string
975 975
    @param name: what are the limits for
976
    @type check_std: bool
977
    @param check_std: Whether to check std value or just assume compliance
976 978
    @raise errors.ConfigureError: when specs for given name are not valid
977 979

  
978 980
    """
979 981
    min_v = ipolicy[constants.ISPECS_MIN].get(name, 0)
980
    std_v = ipolicy[constants.ISPECS_STD].get(name, min_v)
982

  
983
    if check_std:
984
      std_v = ipolicy[constants.ISPECS_STD].get(name, min_v)
985
      std_msg = std_v
986
    else:
987
      std_v = min_v
988
      std_msg = "-"
989

  
981 990
    max_v = ipolicy[constants.ISPECS_MAX].get(name, std_v)
982 991
    err = ("Invalid specification of min/max/std values for %s: %s/%s/%s" %
983 992
           (name,
984 993
            ipolicy[constants.ISPECS_MIN].get(name, "-"),
985 994
            ipolicy[constants.ISPECS_MAX].get(name, "-"),
986
            ipolicy[constants.ISPECS_STD].get(name, "-")))
995
            std_msg))
987 996
    if min_v > std_v or std_v > max_v:
988 997
      raise errors.ConfigurationError(err)
989 998

  

Also available in: Unified diff