Commit 7eac4a4d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add new /2/features RAPI resource

The /2/features RAPI resource can be used to detect optional
features implemented by the RAPI server. This will be used
to recognize servers implementing a new request format for
instance creation requests.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarGuido Trotter <>
parent 565083ef
......@@ -280,6 +280,19 @@ It supports the following commands: ``PUT``.
Redistribute configuration to all nodes. The result will be a job id.
Returns a list of features supported by the RAPI server. Available
Instance creation request data version 1 supported.
......@@ -39,6 +39,7 @@ HTTP_GET = "GET"
HTTP_OK = 200
HTTP_APP_JSON = "application/json"
REPLACE_DISK_PRI = "replace_on_primary"
......@@ -433,6 +434,23 @@ class GanetiRapiClient(object):
return self._SendRequest(HTTP_GET, "/version", None, None)
def GetFeatures(self):
"""Gets the list of optional features supported by RAPI server.
@rtype: list
@return: List of optional features
return self._SendRequest(HTTP_GET, "/%s/features" % GANETI_RAPI_VERSION,
None, None)
except GanetiApiError, err:
# Older RAPI servers don't support this resource
if err.code == HTTP_NOT_FOUND:
return []
def GetOperatingSystems(self):
"""Gets the Operating Systems running in the Ganeti cluster.
......@@ -216,6 +216,7 @@ def GetHandlers(node_name_pattern, instance_name_pattern, job_id_pattern):
"/2/info": rlib2.R_2_info,
"/2/os": rlib2.R_2_os,
"/2/redistribute-config": rlib2.R_2_redist_config,
"/2/features": rlib2.R_2_features,
......@@ -118,6 +118,18 @@ class R_2_info(baserlib.R_Generic):
return client.QueryClusterInfo()
class R_2_features(baserlib.R_Generic):
"""/2/features resource.
def GET():
"""Returns list of optional RAPI features implemented.
return []
class R_2_os(baserlib.R_Generic):
"""/2/os resource.
......@@ -190,6 +190,12 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
self.assertEqual(2, self.client.GetVersion())
def testGetFeatures(self):
for features in [[], ["foo", "bar", "baz"]]:
self.assertEqual(features, self.client.GetFeatures())
def testGetOperatingSystems(self):
self.assertEqual(["beos"], self.client.GetOperatingSystems())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment