From 75f53ffe807b131be845c9ba6975741d66ed1c37 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 11 May 2010 16:14:30 +0200 Subject: [PATCH] RAPI client: No longer check storage type locally Only the RAPI server (actually masterd) knows which storage types are valid. The exception can no longer be raised as the type is only checked in the job. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/rapi/client.py | 29 ----------------------------- test/ganeti.rapi.client_unittest.py | 12 ------------ 2 files changed, 41 deletions(-) diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 090ec54d2..72e3a51b8 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -54,7 +54,6 @@ VALID_REPLACEMENT_MODES = frozenset([ VALID_NODE_ROLES = frozenset([ "drained", "master", "master-candidate", "offline", "regular", ]) -VALID_STORAGE_TYPES = frozenset(["file", "lvm-pv", "lvm-vg"]) class Error(Exception): @@ -87,13 +86,6 @@ class InvalidReplacementMode(Error): pass -class InvalidStorageType(Error): - """Raised when an invalid storage type is used. - - """ - pass - - class InvalidNodeRole(Error): """Raised when an invalid node role is used. @@ -421,14 +413,6 @@ class GanetiRapiClient(object): return response_content - @staticmethod - def _CheckStorageType(storage_type): - """Checks a storage type for validity. - - """ - if storage_type not in VALID_STORAGE_TYPES: - raise InvalidStorageType("%s is an invalid storage type" % storage_type) - def GetVersion(self): """Gets the Remote API version running on the cluster. @@ -965,12 +949,7 @@ class GanetiRapiClient(object): @rtype: int @return: job id where results can be retrieved - @raise InvalidStorageType: If an invalid storage type is specified - """ - # TODO: Add default for storage_type & output_fields - self._CheckStorageType(storage_type) - query = [ ("storage_type", storage_type), ("output_fields", output_fields), @@ -995,11 +974,7 @@ class GanetiRapiClient(object): @rtype: int @return: job id - @raise InvalidStorageType: If an invalid storage type is specified - """ - self._CheckStorageType(storage_type) - query = [ ("storage_type", storage_type), ("name", name), @@ -1023,11 +998,7 @@ class GanetiRapiClient(object): @rtype: int @return: job id - @raise InvalidStorageType: If an invalid storage type is specified - """ - self._CheckStorageType(storage_type) - query = [ ("storage_type", storage_type), ("name", name), diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index 6089352ad..8bf9f463b 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -418,10 +418,6 @@ class GanetiRapiClientTests(testutils.GanetiTestCase): self.assertQuery("storage_type", ["lvm-pv"]) self.assertQuery("output_fields", ["fields"]) - self.assertRaises(client.InvalidStorageType, - self.client.GetNodeStorageUnits, - "node-y", "floppy-disk", "fields") - def testModifyNodeStorageUnits(self): self.rapi.AddResponse("14") self.assertEqual(14, @@ -431,10 +427,6 @@ class GanetiRapiClientTests(testutils.GanetiTestCase): self.assertQuery("storage_type", ["lvm-pv"]) self.assertQuery("name", ["hda"]) - self.assertRaises(client.InvalidStorageType, - self.client.ModifyNodeStorageUnits, - "node-n", "floppy-disk", "hdc") - def testRepairNodeStorageUnits(self): self.rapi.AddResponse("99") self.assertEqual(99, self.client.RepairNodeStorageUnits("node-z", "lvm-pv", @@ -444,10 +436,6 @@ class GanetiRapiClientTests(testutils.GanetiTestCase): self.assertQuery("storage_type", ["lvm-pv"]) self.assertQuery("name", ["hda"]) - self.assertRaises(client.InvalidStorageType, - self.client.RepairNodeStorageUnits, - "node-n", "floppy-disk", "hdc") - def testGetNodeTags(self): self.rapi.AddResponse("[\"fry\", \"bender\"]") self.assertEqual(["fry", "bender"], self.client.GetNodeTags("node-k")) -- GitLab