Skip to content
Snippets Groups Projects
Commit 75f53ffe authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

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: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent a198b2d9
No related branches found
No related tags found
No related merge requests found
......@@ -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),
......
......@@ -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"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment