summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/batch.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-01-13 14:29:16 -0500
committerSimo Sorce <ssorce@redhat.com>2011-01-14 14:26:22 -0500
commitc69d8084c17c5d94240bda9447ed9546159608a5 (patch)
treecbb69cb18d98ddea93c0bd1ea1c706026d0fe94e /ipalib/plugins/batch.py
parentc94d20cfd8cc1bd8cd8152b19d6807b654286197 (diff)
downloadfreeipa-c69d8084c17c5d94240bda9447ed9546159608a5.tar.gz
freeipa-c69d8084c17c5d94240bda9447ed9546159608a5.tar.xz
freeipa-c69d8084c17c5d94240bda9447ed9546159608a5.zip
Add API version and have server reject incompatible clients.
This patch contains 2 parts. The first part is a small utility to create and validate the current API. To do this it needs to load ipalib which on a fresh system introduces a few problems, namely that it relies on a python plugin to set the default encoding to utf8. For our purposes we can skip that. It is also important that any optional plugins be loadable so the API can be examined. The second part is a version exchange between the client and server. The version has a major and a minor version. The major verion is updated whenever existing API changes. The minor version is updated when new API is added. A request will be rejected if either the major versions don't match or if the client major version is higher than then server major version (though by implication new API would return a command not found if allowed to proceed). To determine the API version of the server from a client use the ping command. ticket 584
Diffstat (limited to 'ipalib/plugins/batch.py')
-rw-r--r--ipalib/plugins/batch.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index 07c50600a..f6f662f28 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -33,7 +33,7 @@ where the contenst of the file batch_request.json follow the below example
{"method":"user_show","params":[["admin"],{"all":true}]}
],{}],"id":1}
-THe format of the response is nested the same way. At the top you will see
+The format of the response is nested the same way. At the top you will see
"error": null,
"id": 1,
"result": {
@@ -51,6 +51,7 @@ from ipalib import Str, List
from ipalib.output import Output
from ipalib import output
from ipalib.text import _
+from ipapython.version import API_VERSION
class batch(Command):
INTERNAL = True
@@ -61,6 +62,17 @@ class batch(Command):
),
)
+ take_options = (
+ Str('version',
+ cli_name='version',
+ doc=_('Client version. Used to determine if server will accept request.'),
+ exclude='webui',
+ flags=['no_option', 'no_output'],
+ default=API_VERSION,
+ autofill=True,
+ )
+ )
+
has_output = (
Output('count', int, doc=_('')),
Output('results', list, doc=_(''))