"""
if value in [None, constants.VALUE_AUTO]:
return None
- max_v = ipolicy[constants.MAX_ISPECS].get(name, value)
- min_v = ipolicy[constants.MIN_ISPECS].get(name, value)
+ max_v = ipolicy[constants.ISPECS_MAX].get(name, value)
+ min_v = ipolicy[constants.ISPECS_MIN].get(name, value)
if value > max_v or min_v > value:
return ("%s value %s is not in range [%s, %s]" %
(name, value, min_v, max_v))
nic_count = len(instance.nics)
test_settings = [
- (constants.MEM_SIZE_SPEC, mem_size),
- (constants.CPU_COUNT_SPEC, cpu_count),
- (constants.DISK_COUNT_SPEC, disk_count),
- (constants.NIC_COUNT_SPEC, nic_count),
- ] + map((lambda d: (constants.DISK_SIZE_SPEC, d)), disk_sizes)
+ (constants.ISPEC_MEM_SIZE, mem_size),
+ (constants.ISPEC_CPU_COUNT, cpu_count),
+ (constants.ISPEC_DISK_COUNT, disk_count),
+ (constants.ISPEC_NIC_COUNT, nic_count),
+ ] + map((lambda d: (constants.ISPEC_DISK_SIZE, d)), disk_sizes)
for (name, value) in test_settings:
test_result = _CheckMinMaxSpecs(name, ipolicy, value)
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
# instance specs
-MEM_SIZE_SPEC = "memory-size"
-CPU_COUNT_SPEC = "cpu-count"
-DISK_COUNT_SPEC = "disk-count"
-DISK_SIZE_SPEC = "disk-size"
-NIC_COUNT_SPEC = "nic-count"
+ISPEC_MEM_SIZE = "memory-size"
+ISPEC_CPU_COUNT = "cpu-count"
+ISPEC_DISK_COUNT = "disk-count"
+ISPEC_DISK_SIZE = "disk-size"
+ISPEC_NIC_COUNT = "nic-count"
ISPECS_PARAMETER_TYPES = {
- MEM_SIZE_SPEC: VTYPE_INT,
- CPU_COUNT_SPEC: VTYPE_INT,
- DISK_COUNT_SPEC: VTYPE_INT,
- DISK_SIZE_SPEC: VTYPE_INT,
- NIC_COUNT_SPEC: VTYPE_INT,
+ ISPEC_MEM_SIZE: VTYPE_INT,
+ ISPEC_CPU_COUNT: VTYPE_INT,
+ ISPEC_DISK_COUNT: VTYPE_INT,
+ ISPEC_DISK_SIZE: VTYPE_INT,
+ ISPEC_NIC_COUNT: VTYPE_INT,
}
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
-MIN_ISPECS = "min"
-MAX_ISPECS = "max"
-STD_ISPECS = "std"
+ISPECS_MIN = "min"
+ISPECS_MAX = "max"
+ISPECS_STD = "std"
IPOLICY_PARAMETERS = frozenset([
- MIN_ISPECS,
- MAX_ISPECS,
- STD_ISPECS
+ ISPECS_MIN,
+ ISPECS_MAX,
+ ISPECS_STD,
])
# Node parameter names
}
IPOLICY_DEFAULTS = {
- MIN_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
+ ISPECS_MIN: {
+ ISPEC_MEM_SIZE: 128,
+ ISPEC_CPU_COUNT: 1,
+ ISPEC_DISK_COUNT: 1,
+ ISPEC_DISK_SIZE: 1024,
+ ISPEC_NIC_COUNT: 1,
},
- MAX_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
+ ISPECS_MAX: {
+ ISPEC_MEM_SIZE: 128,
+ ISPEC_CPU_COUNT: 1,
+ ISPEC_DISK_COUNT: 1,
+ ISPEC_DISK_SIZE: 1024,
+ ISPEC_NIC_COUNT: 1,
},
- STD_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
+ ISPECS_STD: {
+ ISPEC_MEM_SIZE: 128,
+ ISPEC_CPU_COUNT: 1,
+ ISPEC_DISK_COUNT: 1,
+ ISPEC_DISK_SIZE: 1024,
+ ISPEC_NIC_COUNT: 1,
}
}
# constants used to create InstancePolicy dictionary
TISPECS_GROUP_TYPES = {
- constants.MIN_ISPECS: constants.VTYPE_INT,
- constants.MAX_ISPECS: constants.VTYPE_INT,
+ constants.ISPECS_MIN: constants.VTYPE_INT,
+ constants.ISPECS_MAX: constants.VTYPE_INT,
}
TISPECS_CLUSTER_TYPES = {
- constants.MIN_ISPECS: constants.VTYPE_INT,
- constants.MAX_ISPECS: constants.VTYPE_INT,
- constants.STD_ISPECS: constants.VTYPE_INT,
+ constants.ISPECS_MIN: constants.VTYPE_INT,
+ constants.ISPECS_MAX: constants.VTYPE_INT,
+ constants.ISPECS_STD: constants.VTYPE_INT,
}
"""
return dict([
- (constants.MIN_ISPECS, dict()),
- (constants.MAX_ISPECS, dict()),
- (constants.STD_ISPECS, dict()),
+ (constants.ISPECS_MIN, dict()),
+ (constants.ISPECS_MAX, dict()),
+ (constants.ISPECS_STD, dict()),
])
"""
# prepare ipolicy dict
ipolicy_transposed = {
- constants.MEM_SIZE_SPEC: ispecs_mem_size,
- constants.CPU_COUNT_SPEC: ispecs_cpu_count,
- constants.DISK_COUNT_SPEC: ispecs_disk_count,
- constants.DISK_SIZE_SPEC: ispecs_disk_size,
- constants.NIC_COUNT_SPEC: ispecs_nic_count,
+ constants.ISPEC_MEM_SIZE: ispecs_mem_size,
+ constants.ISPEC_CPU_COUNT: ispecs_cpu_count,
+ constants.ISPEC_DISK_COUNT: ispecs_disk_count,
+ constants.ISPEC_DISK_SIZE: ispecs_disk_size,
+ constants.ISPEC_NIC_COUNT: ispecs_nic_count,
}
# first, check that the values given are correct
@raise errors.ConfigureError: when specs for given name are not valid
"""
- min_v = ipolicy[constants.MIN_ISPECS].get(name, 0)
- std_v = ipolicy[constants.STD_ISPECS].get(name, min_v)
- max_v = ipolicy[constants.MAX_ISPECS].get(name, std_v)
+ min_v = ipolicy[constants.ISPECS_MIN].get(name, 0)
+ std_v = ipolicy[constants.ISPECS_STD].get(name, min_v)
+ max_v = ipolicy[constants.ISPECS_MAX].get(name, std_v)
err = ("Invalid specification of min/max/std values for %s: %s/%s/%s" %
(name,
- ipolicy[constants.MIN_ISPECS].get(name, "-"),
- ipolicy[constants.MAX_ISPECS].get(name, "-"),
- ipolicy[constants.STD_ISPECS].get(name, "-")))
+ ipolicy[constants.ISPECS_MIN].get(name, "-"),
+ ipolicy[constants.ISPECS_MAX].get(name, "-"),
+ ipolicy[constants.ISPECS_STD].get(name, "-")))
if min_v > std_v or std_v > max_v:
raise errors.ConfigurationError(err)