diff --git a/doc/rapi.rst b/doc/rapi.rst index 7ed29a80319c97744d9bbbd3ed4b528ba49da629..a9f413ca12e2528416adca33ba4d80377f335e90 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -239,30 +239,8 @@ Resources ``/`` +++++ -The root resource. - -It supports the following commands: ``GET``. - -``GET`` -~~~~~~~ - -Shows the list of mapped resources. - -Returns: a dictionary with 'name' and 'uri' keys for each of them. - -``/2`` -++++++ - -The ``/2`` resource, the root of the version 2 API. - -It supports the following commands: ``GET``. - -``GET`` -~~~~~~~ - -Show the list of mapped resources. - -Returns: a dictionary with ``name`` and ``uri`` keys for each of them. +The root resource. Has no function, but for legacy reasons the ``GET`` +method is supported. ``/2/info`` +++++++++++ diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index 34c13fd1b16224ae23bcfd3185789eb52df064d1..26a71af85a18fdc0b82ff9d0a93bfc3fadad763b 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -33,7 +33,6 @@ from ganeti import constants from ganeti import http from ganeti import utils -from ganeti.rapi import baserlib from ganeti.rapi import rlib2 @@ -89,66 +88,6 @@ class Mapper: return (handler, groups, args) -class R_root(baserlib.R_Generic): - """/ resource. - - """ - _ROOT_PATTERN = re.compile("^R_([a-zA-Z0-9]+)$") - - @classmethod - def GET(cls): - """Show the list of mapped resources. - - @return: a dictionary with 'name' and 'uri' keys for each of them. - - """ - rootlist = [] - for handler in CONNECTOR.values(): - m = cls._ROOT_PATTERN.match(handler.__name__) - if m: - name = m.group(1) - if name != "root": - rootlist.append(name) - - return baserlib.BuildUriList(rootlist, "/%s") - - -def _getResources(id_): - """Return a list of resources underneath given id. - - This is to generalize querying of version resources lists. - - @return: a list of resources names. - - """ - r_pattern = re.compile("^R_%s_([a-zA-Z0-9]+)$" % id_) - - rlist = [] - for handler in CONNECTOR.values(): - m = r_pattern.match(handler.__name__) - if m: - name = m.group(1) - rlist.append(name) - - return rlist - - -class R_2(baserlib.R_Generic): - """/2 resource. - - This is the root of the version 2 API. - - """ - @staticmethod - def GET(): - """Show the list of mapped resources. - - @return: a dictionary with 'name' and 'uri' keys for each of them. - - """ - return baserlib.BuildUriList(_getResources("2"), "/2/%s") - - def GetHandlers(node_name_pattern, instance_name_pattern, group_name_pattern, job_id_pattern, disk_pattern, query_res_pattern): @@ -160,12 +99,10 @@ def GetHandlers(node_name_pattern, instance_name_pattern, # is more flexible and future-compatible than versioning the whole remote # API. return { - "/": R_root, + "/": rlib2.R_root, "/version": rlib2.R_version, - "/2": R_2, - "/2/nodes": rlib2.R_2_nodes, re.compile(r"^/2/nodes/(%s)$" % node_name_pattern): rlib2.R_2_nodes_name, diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index fb32e8090644722dd2fc3aff2db20a8afbbe89ee..b6d9abd8aac222280017c04b925f6e5c820db220 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -148,6 +148,18 @@ ALL_FEATURES = frozenset([ _WFJC_TIMEOUT = 10 +class R_root(baserlib.R_Generic): + """/ resource. + + """ + @staticmethod + def GET(): + """Supported for legacy reasons. + + """ + return None + + class R_version(baserlib.R_Generic): """/version resource. diff --git a/test/docs_unittest.py b/test/docs_unittest.py index 82e5a9d068f175fcb96a10a09b861200b31f2200..e75092dd801a12e151f6ff0e059c502add9793e4 100755 --- a/test/docs_unittest.py +++ b/test/docs_unittest.py @@ -142,7 +142,7 @@ class TestDocs(unittest.TestCase): prevline = line - prefix_exception = frozenset(["/", "/version", "/2"]) + prefix_exception = frozenset(["/", "/version"]) undocumented = [] used_uris = [] diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index d7af45ad3ca6ec6295727ed670fe94e42331c6ce..7273f14da29e8e4cbea44b8aea71893ace169b0b 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -45,8 +45,7 @@ _URI_RE = re.compile(r"https://(?P<host>.*):(?P<port>\d+)(?P<path>/.*)") # List of resource handlers which aren't used by the RAPI client _KNOWN_UNUSED = set([ - connector.R_root, - connector.R_2, + rlib2.R_root, ]) # Global variable for collecting used handlers diff --git a/test/ganeti.rapi.resources_unittest.py b/test/ganeti.rapi.resources_unittest.py index 70f68b5b172412953c266e53fbd20b20e97ec020..5d53118837b4ddf4f30225608a612d0b897ca083 100755 --- a/test/ganeti.rapi.resources_unittest.py +++ b/test/ganeti.rapi.resources_unittest.py @@ -69,19 +69,5 @@ class MapperTests(unittest.TestCase): self._TestFailingUri("/instances/does/not/exist") -class R_RootTests(unittest.TestCase): - """Testing for R_root class.""" - - def setUp(self): - self.root = connector.R_root(None, None, None) - - def testGet(self): - expected = [ - {'name': '2', 'uri': '/2'}, - {'name': 'version', 'uri': '/version'}, - ] - self.assertEquals(self.root.GET(), expected) - - if __name__ == '__main__': testutils.GanetiTestProgram()