Yeela Kaplan has uploaded a new change for review.

Change subject: jsonrpc cli: allow client to return compatible results
......................................................................

jsonrpc cli: allow client to return compatible results

to xmlrpc.

Bridge transforms the return value for different verbs
results returning from vdsm API.
Some code expects the old return results of API
compatible with xmlrpc.

The compat parameter allows us to return a value
that is compatible with the way xmlrpc is parsed
and we'll be able to remove this once we stop
supporting xmlrpc API.

Until then using this intermediate step is the most
straight-forward way and saves us the unnecessary
hassle of re-translating the bridge work
once its done parsing the result from API.

Change-Id: Id0bbbb46f622e60824cf5d25670fd16889f4fc51
Signed-off-by: Yeela Kaplan <[email protected]>
---
M lib/vdsm/jsonrpcvdscli.py
M lib/vdsm/response.py
2 files changed, 22 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/47923/1

diff --git a/lib/vdsm/jsonrpcvdscli.py b/lib/vdsm/jsonrpcvdscli.py
index c5a4df9..4fb197d 100644
--- a/lib/vdsm/jsonrpcvdscli.py
+++ b/lib/vdsm/jsonrpcvdscli.py
@@ -46,9 +46,10 @@
 
 class _Server(object):
 
-    def __init__(self, client):
+    def __init__(self, client, compat):
         self._vdsmapi = vdsmapi.get_api()
         self._client = client
+        self._compat = compat
 
     def _prepare_args(self, className, methodName, args, kwargs):
         sym = self._vdsmapi['commands'][className][methodName]
@@ -82,6 +83,9 @@
         if resp.error is not None:
             return response.error_raw(resp.error["code"],
                                       resp.error["message"])
+
+        if not self._compat:
+            return response.success_raw(resp.result)
 
         if resp.result and resp.result is not True:
             # None is translated to True inside our JSONRPC implementation
@@ -126,7 +130,7 @@
 def connect(requestQueue, stompClient=None,
             host=None, port=None,
             useSSL=None,
-            responseQueue=None):
+            responseQueue=None, compat=True):
     if not stompClient:
         client = _create(requestQueue,
                          host, port, useSSL,
@@ -138,4 +142,4 @@
             str(uuid4())
         )
 
-    return _Server(client)
+    return _Server(client, compat)
diff --git a/lib/vdsm/response.py b/lib/vdsm/response.py
index 62ed49e..160898f 100644
--- a/lib/vdsm/response.py
+++ b/lib/vdsm/response.py
@@ -41,6 +41,21 @@
     return kwargs
 
 
+def success_raw(result=None, message=None):
+    ret = {
+        'status':
+            {
+                "code": doneCode["code"],
+                "message": message or doneCode["message"],
+            }
+    }
+
+    if result:
+        ret['result'] = result
+
+    return ret
+
+
 def error(name, message=None):
     status = errCode[name]["status"]
     return {


-- 
To view, visit https://gerrit.ovirt.org/47923
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0bbbb46f622e60824cf5d25670fd16889f4fc51
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to