Revision 1068639f lib/rapi/client.py
b/lib/rapi/client.py | ||
---|---|---|
45 | 45 |
REPLACE_DISK_SECONDARY = "replace_on_secondary" |
46 | 46 |
REPLACE_DISK_CHG = "replace_new_secondary" |
47 | 47 |
REPLACE_DISK_AUTO = "replace_auto" |
48 |
VALID_NODE_ROLES = frozenset([ |
|
49 |
"drained", "master", "master-candidate", "offline", "regular", |
|
50 |
]) |
|
48 |
|
|
49 |
NODE_ROLE_DRAINED = "drained" |
|
50 |
NODE_ROLE_MASTER_CANDIATE = "master-candidate" |
|
51 |
NODE_ROLE_MASTER = "master" |
|
52 |
NODE_ROLE_OFFLINE = "offline" |
|
53 |
NODE_ROLE_REGULAR = "regular" |
|
51 | 54 |
|
52 | 55 |
|
53 | 56 |
class Error(Exception): |
... | ... | |
73 | 76 |
self.code = code |
74 | 77 |
|
75 | 78 |
|
76 |
class InvalidNodeRole(Error): |
|
77 |
"""Raised when an invalid node role is used. |
|
78 |
|
|
79 |
""" |
|
80 |
pass |
|
81 |
|
|
82 |
|
|
83 | 79 |
def FormatX509Name(x509_name): |
84 | 80 |
"""Formats an X509 name. |
85 | 81 |
|
... | ... | |
932 | 928 |
@rtype: int |
933 | 929 |
@return: job id |
934 | 930 |
|
935 |
@raise InvalidNodeRole: If an invalid node role is specified |
|
936 |
|
|
937 | 931 |
""" |
938 |
if role not in VALID_NODE_ROLES: |
|
939 |
raise InvalidNodeRole("%s is not a valid node role" % role) |
|
940 |
|
|
941 |
query = [("force", force)] |
|
932 |
query = [ |
|
933 |
("force", force), |
|
934 |
] |
|
942 | 935 |
|
943 | 936 |
return self._SendRequest(HTTP_PUT, |
944 | 937 |
("/%s/nodes/%s/role" % |
Also available in: Unified diff