Revision 4f725341

b/lib/cmdlib.py
1028 1028
  """
1029 1029
  if value in [None, constants.VALUE_AUTO]:
1030 1030
    return None
1031
  max_v = ipolicy[constants.MAX_ISPECS].get(name, value)
1032
  min_v = ipolicy[constants.MIN_ISPECS].get(name, value)
1031
  max_v = ipolicy[constants.ISPECS_MAX].get(name, value)
1032
  min_v = ipolicy[constants.ISPECS_MIN].get(name, value)
1033 1033
  if value > max_v or min_v > value:
1034 1034
    return ("%s value %s is not in range [%s, %s]" %
1035 1035
            (name, value, min_v, max_v))
......
2151 2151
    nic_count = len(instance.nics)
2152 2152

  
2153 2153
    test_settings = [
2154
      (constants.MEM_SIZE_SPEC, mem_size),
2155
      (constants.CPU_COUNT_SPEC, cpu_count),
2156
      (constants.DISK_COUNT_SPEC, disk_count),
2157
      (constants.NIC_COUNT_SPEC, nic_count),
2158
      ] + map((lambda d: (constants.DISK_SIZE_SPEC, d)), disk_sizes)
2154
      (constants.ISPEC_MEM_SIZE, mem_size),
2155
      (constants.ISPEC_CPU_COUNT, cpu_count),
2156
      (constants.ISPEC_DISK_COUNT, disk_count),
2157
      (constants.ISPEC_NIC_COUNT, nic_count),
2158
      ] + map((lambda d: (constants.ISPEC_DISK_SIZE, d)), disk_sizes)
2159 2159

  
2160 2160
    for (name, value) in test_settings:
2161 2161
      test_result = _CheckMinMaxSpecs(name, ipolicy, value)
b/lib/constants.py
922 922
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
923 923

  
924 924
# instance specs
925
MEM_SIZE_SPEC = "memory-size"
926
CPU_COUNT_SPEC = "cpu-count"
927
DISK_COUNT_SPEC = "disk-count"
928
DISK_SIZE_SPEC = "disk-size"
929
NIC_COUNT_SPEC = "nic-count"
925
ISPEC_MEM_SIZE = "memory-size"
926
ISPEC_CPU_COUNT = "cpu-count"
927
ISPEC_DISK_COUNT = "disk-count"
928
ISPEC_DISK_SIZE = "disk-size"
929
ISPEC_NIC_COUNT = "nic-count"
930 930

  
931 931
ISPECS_PARAMETER_TYPES = {
932
  MEM_SIZE_SPEC: VTYPE_INT,
933
  CPU_COUNT_SPEC: VTYPE_INT,
934
  DISK_COUNT_SPEC: VTYPE_INT,
935
  DISK_SIZE_SPEC: VTYPE_INT,
936
  NIC_COUNT_SPEC: VTYPE_INT,
932
  ISPEC_MEM_SIZE: VTYPE_INT,
933
  ISPEC_CPU_COUNT: VTYPE_INT,
934
  ISPEC_DISK_COUNT: VTYPE_INT,
935
  ISPEC_DISK_SIZE: VTYPE_INT,
936
  ISPEC_NIC_COUNT: VTYPE_INT,
937 937
  }
938 938

  
939 939
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
940 940

  
941
MIN_ISPECS = "min"
942
MAX_ISPECS = "max"
943
STD_ISPECS = "std"
941
ISPECS_MIN = "min"
942
ISPECS_MAX = "max"
943
ISPECS_STD = "std"
944 944

  
945 945
IPOLICY_PARAMETERS = frozenset([
946
  MIN_ISPECS,
947
  MAX_ISPECS,
948
  STD_ISPECS
946
  ISPECS_MIN,
947
  ISPECS_MAX,
948
  ISPECS_STD,
949 949
  ])
950 950

  
951 951
# Node parameter names
......
1815 1815
  }
1816 1816

  
1817 1817
IPOLICY_DEFAULTS = {
1818
  MIN_ISPECS: {
1819
    MEM_SIZE_SPEC: 128,
1820
    CPU_COUNT_SPEC: 1,
1821
    DISK_COUNT_SPEC: 1,
1822
    DISK_SIZE_SPEC: 1024,
1823
    NIC_COUNT_SPEC: 1,
1818
  ISPECS_MIN: {
1819
    ISPEC_MEM_SIZE: 128,
1820
    ISPEC_CPU_COUNT: 1,
1821
    ISPEC_DISK_COUNT: 1,
1822
    ISPEC_DISK_SIZE: 1024,
1823
    ISPEC_NIC_COUNT: 1,
1824 1824
    },
1825
  MAX_ISPECS: {
1826
    MEM_SIZE_SPEC: 128,
1827
    CPU_COUNT_SPEC: 1,
1828
    DISK_COUNT_SPEC: 1,
1829
    DISK_SIZE_SPEC: 1024,
1830
    NIC_COUNT_SPEC: 1,
1825
  ISPECS_MAX: {
1826
    ISPEC_MEM_SIZE: 128,
1827
    ISPEC_CPU_COUNT: 1,
1828
    ISPEC_DISK_COUNT: 1,
1829
    ISPEC_DISK_SIZE: 1024,
1830
    ISPEC_NIC_COUNT: 1,
1831 1831
    },
1832
  STD_ISPECS: {
1833
    MEM_SIZE_SPEC: 128,
1834
    CPU_COUNT_SPEC: 1,
1835
    DISK_COUNT_SPEC: 1,
1836
    DISK_SIZE_SPEC: 1024,
1837
    NIC_COUNT_SPEC: 1,
1832
  ISPECS_STD: {
1833
    ISPEC_MEM_SIZE: 128,
1834
    ISPEC_CPU_COUNT: 1,
1835
    ISPEC_DISK_COUNT: 1,
1836
    ISPEC_DISK_SIZE: 1024,
1837
    ISPEC_NIC_COUNT: 1,
1838 1838
    }
1839 1839
  }
1840 1840

  
b/lib/objects.py
57 57

  
58 58
# constants used to create InstancePolicy dictionary
59 59
TISPECS_GROUP_TYPES = {
60
  constants.MIN_ISPECS: constants.VTYPE_INT,
61
  constants.MAX_ISPECS: constants.VTYPE_INT,
60
  constants.ISPECS_MIN: constants.VTYPE_INT,
61
  constants.ISPECS_MAX: constants.VTYPE_INT,
62 62
}
63 63

  
64 64
TISPECS_CLUSTER_TYPES = {
65
  constants.MIN_ISPECS: constants.VTYPE_INT,
66
  constants.MAX_ISPECS: constants.VTYPE_INT,
67
  constants.STD_ISPECS: constants.VTYPE_INT,
65
  constants.ISPECS_MIN: constants.VTYPE_INT,
66
  constants.ISPECS_MAX: constants.VTYPE_INT,
67
  constants.ISPECS_STD: constants.VTYPE_INT,
68 68
  }
69 69

  
70 70

  
......
166 166

  
167 167
  """
168 168
  return dict([
169
    (constants.MIN_ISPECS, dict()),
170
    (constants.MAX_ISPECS, dict()),
171
    (constants.STD_ISPECS, dict()),
169
    (constants.ISPECS_MIN, dict()),
170
    (constants.ISPECS_MAX, dict()),
171
    (constants.ISPECS_STD, dict()),
172 172
    ])
173 173

  
174 174

  
......
185 185
  """
186 186
  # prepare ipolicy dict
187 187
  ipolicy_transposed = {
188
    constants.MEM_SIZE_SPEC: ispecs_mem_size,
189
    constants.CPU_COUNT_SPEC: ispecs_cpu_count,
190
    constants.DISK_COUNT_SPEC: ispecs_disk_count,
191
    constants.DISK_SIZE_SPEC: ispecs_disk_size,
192
    constants.NIC_COUNT_SPEC: ispecs_nic_count,
188
    constants.ISPEC_MEM_SIZE: ispecs_mem_size,
189
    constants.ISPEC_CPU_COUNT: ispecs_cpu_count,
190
    constants.ISPEC_DISK_COUNT: ispecs_disk_count,
191
    constants.ISPEC_DISK_SIZE: ispecs_disk_size,
192
    constants.ISPEC_NIC_COUNT: ispecs_nic_count,
193 193
    }
194 194

  
195 195
  # first, check that the values given are correct
......
881 881
    @raise errors.ConfigureError: when specs for given name are not valid
882 882

  
883 883
    """
884
    min_v = ipolicy[constants.MIN_ISPECS].get(name, 0)
885
    std_v = ipolicy[constants.STD_ISPECS].get(name, min_v)
886
    max_v = ipolicy[constants.MAX_ISPECS].get(name, std_v)
884
    min_v = ipolicy[constants.ISPECS_MIN].get(name, 0)
885
    std_v = ipolicy[constants.ISPECS_STD].get(name, min_v)
886
    max_v = ipolicy[constants.ISPECS_MAX].get(name, std_v)
887 887
    err = ("Invalid specification of min/max/std values for %s: %s/%s/%s" %
888 888
           (name,
889
            ipolicy[constants.MIN_ISPECS].get(name, "-"),
890
            ipolicy[constants.MAX_ISPECS].get(name, "-"),
891
            ipolicy[constants.STD_ISPECS].get(name, "-")))
889
            ipolicy[constants.ISPECS_MIN].get(name, "-"),
890
            ipolicy[constants.ISPECS_MAX].get(name, "-"),
891
            ipolicy[constants.ISPECS_STD].get(name, "-")))
892 892
    if min_v > std_v or std_v > max_v:
893 893
      raise errors.ConfigurationError(err)
894 894

  

Also available in: Unified diff