Revision 75f53ffe lib/rapi/client.py
b/lib/rapi/client.py | ||
---|---|---|
54 | 54 |
VALID_NODE_ROLES = frozenset([ |
55 | 55 |
"drained", "master", "master-candidate", "offline", "regular", |
56 | 56 |
]) |
57 |
VALID_STORAGE_TYPES = frozenset(["file", "lvm-pv", "lvm-vg"]) |
|
58 | 57 |
|
59 | 58 |
|
60 | 59 |
class Error(Exception): |
... | ... | |
87 | 86 |
pass |
88 | 87 |
|
89 | 88 |
|
90 |
class InvalidStorageType(Error): |
|
91 |
"""Raised when an invalid storage type is used. |
|
92 |
|
|
93 |
""" |
|
94 |
pass |
|
95 |
|
|
96 |
|
|
97 | 89 |
class InvalidNodeRole(Error): |
98 | 90 |
"""Raised when an invalid node role is used. |
99 | 91 |
|
... | ... | |
421 | 413 |
|
422 | 414 |
return response_content |
423 | 415 |
|
424 |
@staticmethod |
|
425 |
def _CheckStorageType(storage_type): |
|
426 |
"""Checks a storage type for validity. |
|
427 |
|
|
428 |
""" |
|
429 |
if storage_type not in VALID_STORAGE_TYPES: |
|
430 |
raise InvalidStorageType("%s is an invalid storage type" % storage_type) |
|
431 |
|
|
432 | 416 |
def GetVersion(self): |
433 | 417 |
"""Gets the Remote API version running on the cluster. |
434 | 418 |
|
... | ... | |
965 | 949 |
@rtype: int |
966 | 950 |
@return: job id where results can be retrieved |
967 | 951 |
|
968 |
@raise InvalidStorageType: If an invalid storage type is specified |
|
969 |
|
|
970 | 952 |
""" |
971 |
# TODO: Add default for storage_type & output_fields |
|
972 |
self._CheckStorageType(storage_type) |
|
973 |
|
|
974 | 953 |
query = [ |
975 | 954 |
("storage_type", storage_type), |
976 | 955 |
("output_fields", output_fields), |
... | ... | |
995 | 974 |
@rtype: int |
996 | 975 |
@return: job id |
997 | 976 |
|
998 |
@raise InvalidStorageType: If an invalid storage type is specified |
|
999 |
|
|
1000 | 977 |
""" |
1001 |
self._CheckStorageType(storage_type) |
|
1002 |
|
|
1003 | 978 |
query = [ |
1004 | 979 |
("storage_type", storage_type), |
1005 | 980 |
("name", name), |
... | ... | |
1023 | 998 |
@rtype: int |
1024 | 999 |
@return: job id |
1025 | 1000 |
|
1026 |
@raise InvalidStorageType: If an invalid storage type is specified |
|
1027 |
|
|
1028 | 1001 |
""" |
1029 |
self._CheckStorageType(storage_type) |
|
1030 |
|
|
1031 | 1002 |
query = [ |
1032 | 1003 |
("storage_type", storage_type), |
1033 | 1004 |
("name", name), |
Also available in: Unified diff