Commit 1068639f authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

RAPI client: Don't check node role in client



Only the server knows which node roles can be set via RAPI.
Constants are provided for convenience.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent bfc2002f
......@@ -45,9 +45,12 @@ REPLACE_DISK_PRI = "replace_on_primary"
REPLACE_DISK_SECONDARY = "replace_on_secondary"
REPLACE_DISK_CHG = "replace_new_secondary"
REPLACE_DISK_AUTO = "replace_auto"
VALID_NODE_ROLES = frozenset([
"drained", "master", "master-candidate", "offline", "regular",
])
NODE_ROLE_DRAINED = "drained"
NODE_ROLE_MASTER_CANDIATE = "master-candidate"
NODE_ROLE_MASTER = "master"
NODE_ROLE_OFFLINE = "offline"
NODE_ROLE_REGULAR = "regular"
class Error(Exception):
......@@ -73,13 +76,6 @@ class GanetiApiError(Error):
self.code = code
class InvalidNodeRole(Error):
"""Raised when an invalid node role is used.
"""
pass
def FormatX509Name(x509_name):
"""Formats an X509 name.
......@@ -932,13 +928,10 @@ class GanetiRapiClient(object):
@rtype: int
@return: job id
@raise InvalidNodeRole: If an invalid node role is specified
"""
if role not in VALID_NODE_ROLES:
raise InvalidNodeRole("%s is not a valid node role" % role)
query = [("force", force)]
query = [
("force", force),
]
return self._SendRequest(HTTP_PUT,
("/%s/nodes/%s/role" %
......
......@@ -428,9 +428,6 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertQuery("force", ["1"])
self.assertEqual("\"master-candidate\"", self.http.last_request.data)
self.assertRaises(client.InvalidNodeRole,
self.client.SetNodeRole, "node-bar", "fake-role")
def testGetNodeStorageUnits(self):
self.rapi.AddResponse("42")
self.assertEqual(42,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment