Change in vdsm[master]: jsonrpc: Implement the JsonRPC server for the next-gen API

danken at redhat.com danken at redhat.com
Mon Nov 12 15:34:04 UTC 2012


Dan Kenigsberg has submitted this change and it was merged.

Change subject: jsonrpc: Implement the JsonRPC server for the next-gen API
......................................................................


jsonrpc: Implement the JsonRPC server for the next-gen API

This patch implements a new Binding plugin to serve the next generation vdsm API
over a JsonRPC wire protocol.  The basic format of a message is:

    <size><json-data>

<size> is an unsigned 64 bit integer in big endian format that indicates the
length of <json-data> in bytes.  <json-data> is either a request or a response
in Javascript object notation (JSON).

A request object has the following fields:
    id:  An integer which will be repeated in the matching response
    methodName:  The name of the API method to be called
    args (optional): A JSON object containing arguments to the method

A response object has the following fields:
    id:  An integer which will be the same as the matching request
    result:  The return value of the method (defined in the API schema)
    error:  A JSON object containing error information
            code:  An integer error code
            message:  Error context information

Method calls are dispatched to vdsm using a MethodBridge.  The DynamicBridge
dispatches calls based on an API schema document and a set of schema exceptions.
In this way, the API can be expanded without the need to add more code to this
server infrastructure.  When a request is made, the DynamicBridge attempts to
resolve 'methodName' to a schema defined method.  If found, the necessary
arguments are collected from the request and the function call is dispatched to
the internal vdsm API.

Schema exceptions:
Currently, vdsm does not completely conform to its own API schema.  It is not
possible to correct all of the discrepencies due to the need to maintain
backwards compatibility with current API users.  To facilitate migration to this
API, the DynamicBridge implements a set of overrides to translate between the
schema-defined API and what is implemented in vdsm today.  There are three types
of method overrides and one type of argument override:

Method overrides:
1. Custom call function:  If a new API does not map directly to an existing vdsm
   API (or multiple functions must be called to get the result), a custom 'call'
   function can be defined for the API.  This function will be called instead of
   trying to find a vdsm API to call.

2. Return field name:  Many vdsm functions' return values are nested in a
   dictionary.  This override specifies the key to use when accessing the result
   so that it can be returned un-nested to the caller.

3. Custom result post-processing function:  Some vdsm APIs return results in a
   non-standard format and a special function must be used to reformat the data
   to comply with the schema.

Type override:
Some data types have a different representation internally to vdsm than we have
defined in the schema.  A type override can be used to convert between the two
formats.  Currently, the only kind of translation we do is to rename fields
within a given type.

Change-Id: Idae0faa80ffc6a5af002a8a7151aa40dc9a6673d
Signed-off-by: Adam Litke <agl at us.ibm.com>
---
M Makefile.am
M configure.ac
M tests/Makefile.am
A tests/apiData.py
A tests/apiTests.py
M tests/run_tests_local.sh.in
M vdsm.spec.in
M vdsm/clientIF.py
M vdsm/config.py.in
A vdsm_api/BindingJsonRpc.py
A vdsm_api/Bridge.py
A vdsm_api/Makefile.am
M vdsm_api/process-schema.py
13 files changed, 780 insertions(+), 4 deletions(-)

Approvals:
  Dan Kenigsberg: Verified; Looks good to me, approved


--
To view, visit http://gerrit.ovirt.org/8614
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idae0faa80ffc6a5af002a8a7151aa40dc9a6673d
Gerrit-PatchSet: 5
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <agl at us.ibm.com>
Gerrit-Reviewer: Adam Litke <agl at us.ibm.com>
Gerrit-Reviewer: Barak Azulay <bazulay at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Ryan Harper <ryanh at us.ibm.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list