From 132cdb87159e56d905dc8b235171e2c9af6208d9 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 13 Sep 2011 12:53:15 +0200 Subject: [PATCH] =?UTF-8?q?rapi:=20Re-add=20=E2=80=9C/2=E2=80=9D=20resourc?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like β/β, it'll just return a JSON null. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- doc/rapi.rst | 5 +++++ lib/rapi/connector.py | 1 + lib/rapi/rlib2.py | 6 ++++++ test/docs_unittest.py | 2 +- test/ganeti.rapi.rlib2_unittest.py | 7 ++++--- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/rapi.rst b/doc/rapi.rst index a9f413ca1..5ea41ca1f 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -242,6 +242,11 @@ Resources The root resource. Has no function, but for legacy reasons the ``GET`` method is supported. +``/2`` +++++++ + +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 26a71af85..fad46e46e 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -100,6 +100,7 @@ def GetHandlers(node_name_pattern, instance_name_pattern, # API. return { "/": rlib2.R_root, + "/2": rlib2.R_2, "/version": rlib2.R_version, diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index 80c695bf7..550af5a93 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -161,6 +161,12 @@ class R_root(baserlib.ResourceBase): return None +class R_2(R_root): + """/2 resource. + + """ + + class R_version(baserlib.ResourceBase): """/version resource. diff --git a/test/docs_unittest.py b/test/docs_unittest.py index e75092dd8..82e5a9d06 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"]) + prefix_exception = frozenset(["/", "/version", "/2"]) undocumented = [] used_uris = [] diff --git a/test/ganeti.rapi.rlib2_unittest.py b/test/ganeti.rapi.rlib2_unittest.py index 16d4d35a7..58127e4f8 100755 --- a/test/ganeti.rapi.rlib2_unittest.py +++ b/test/ganeti.rapi.rlib2_unittest.py @@ -1645,9 +1645,10 @@ class TestSimpleResources(unittest.TestCase): handler = _CreateHandler(rlib2.R_2_features, [], {}, None, self.clfactory) self.assertEqual(set(handler.GET()), rlib2.ALL_FEATURES) - def testRoot(self): - handler = _CreateHandler(rlib2.R_root, [], {}, None, self.clfactory) - self.assertTrue(handler.GET() is None) + def testEmpty(self): + for cls in [rlib2.R_root, rlib2.R_2]: + handler = _CreateHandler(cls, [], {}, None, self.clfactory) + self.assertTrue(handler.GET() is None) def testVersion(self): handler = _CreateHandler(rlib2.R_version, [], {}, None, self.clfactory) -- GitLab