From: Agata Murawska Date: Fri, 9 Dec 2011 09:28:44 +0000 (+0100) Subject: Change constants: ISPECS suffixes to prefixes X-Git-Tag: v2.6.0beta1~548 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/4f725341ab51ad51f95b82e385c3d33026479c7f?hp=5959f75d30de7352520ec7a611614c1fd8b3d95e Change constants: ISPECS suffixes to prefixes Signed-off-by: Agata Murawska Reviewed-by: Iustin Pop --- diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 7788af2..bbbaa25 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1028,8 +1028,8 @@ def _CheckMinMaxSpecs(name, ipolicy, value): """ 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)) @@ -2151,11 +2151,11 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): 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) diff --git a/lib/constants.py b/lib/constants.py index 0d79657..1402761 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -922,30 +922,30 @@ BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES) 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 @@ -1815,26 +1815,26 @@ NICC_DEFAULTS = { } 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, } } diff --git a/lib/objects.py b/lib/objects.py index 1e61b73..1e6162a 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -57,14 +57,14 @@ _UUID = ["uuid"] # 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, } @@ -166,9 +166,9 @@ def MakeEmptyIPolicy(): """ 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()), ]) @@ -185,11 +185,11 @@ def CreateIPolicyFromOpts(ispecs_mem_size=None, """ # 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 @@ -881,14 +881,14 @@ class InstancePolicy(ConfigObject): @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)