diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 86d78fcdf71385852dece1e152f7f5e2360174f3..dccbf95a7bf91afd6155931ff1100efb6b634394 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -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" % diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index 52346dd358c69a4e91d8de3c1ba0410f94e5b67e..0d83580a9dede61bb82ee65ca9981aefcdc0b870 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -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,