Revision ff6c5e55 lib/objects.py
b/lib/objects.py | ||
---|---|---|
105 | 105 |
# list items |
106 | 106 |
for key in [constants.IPOLICY_DTS]: |
107 | 107 |
ret_dict[key] = list(custom_ipolicy.get(key, default_ipolicy[key])) |
108 |
# other items which we know we can directly copy (immutables) |
|
109 |
for key in constants.IPOLICY_PARAMETERS: |
|
110 |
ret_dict[key] = custom_ipolicy.get(key, default_ipolicy[key]) |
|
108 | 111 |
|
109 | 112 |
return ret_dict |
110 | 113 |
|
... | ... | |
908 | 911 |
InstancePolicy.CheckISpecSyntax(ipolicy, param) |
909 | 912 |
if constants.IPOLICY_DTS in ipolicy: |
910 | 913 |
InstancePolicy.CheckDiskTemplates(ipolicy[constants.IPOLICY_DTS]) |
914 |
for key in constants.IPOLICY_PARAMETERS: |
|
915 |
if key in ipolicy: |
|
916 |
InstancePolicy.CheckParameter(key, ipolicy[key]) |
|
911 | 917 |
wrong_keys = frozenset(ipolicy.keys()) - constants.IPOLICY_ALL_KEYS |
912 | 918 |
if wrong_keys: |
913 | 919 |
raise errors.ConfigurationError("Invalid keys in ipolicy: %s" % |
... | ... | |
948 | 954 |
raise errors.ConfigurationError("Invalid disk template(s) %s" % |
949 | 955 |
utils.CommaJoin(wrong)) |
950 | 956 |
|
957 |
@classmethod |
|
958 |
def CheckParameter(cls, key, value): |
|
959 |
"""Checks a parameter. |
|
960 |
|
|
961 |
Currently we expect all parameters to be float values. |
|
962 |
|
|
963 |
""" |
|
964 |
try: |
|
965 |
float(value) |
|
966 |
except (TypeError, ValueError), err: |
|
967 |
raise errors.ConfigurationError("Invalid value for key" " '%s':" |
|
968 |
" '%s', error: %s" % (key, value, err)) |
|
969 |
|
|
951 | 970 |
|
952 | 971 |
class Instance(TaggableObject): |
953 | 972 |
"""Config object representing an instance.""" |
Also available in: Unified diff