Change in vdsm[master]: fence: Fix description of result and JSONRPC marshalling

mperina at redhat.com mperina at redhat.com
Thu Sep 18 07:24:55 UTC 2014


Martin Peřina has uploaded a new change for review.

Change subject: fence: Fix description of result and JSONRPC marshalling
......................................................................

fence: Fix description of result and JSONRPC marshalling

1) Fixes description of fenceNode return value
2) Fixes marshalling of fenceNode return value for JSONRPC

Change-Id: Ib39744828d56de2ec0bc6406d7dcfa116a7ec8d8
Signed-off-by: Martin Perina <mperina at redhat.com>
---
M tests/bridgeTests.py
M vdsm/rpc/Bridge.py
M vdsm/rpc/vdsmapi-schema.json
3 files changed, 42 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/33034/1

diff --git a/tests/bridgeTests.py b/tests/bridgeTests.py
index 195478b..c1eebf1 100644
--- a/tests/bridgeTests.py
+++ b/tests/bridgeTests.py
@@ -90,7 +90,7 @@
         params = obj.get('params', [])
 
         method = getattr(bridge, mangledMethod)
-        self.assertEquals(method(**params), 'on')
+        self.assertEquals(method(**params), {'power': 'on'})
 
     def testMethodWithNoParams(self):
         createFakeAPI()
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index b6dfefa..73970e0 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -284,6 +284,19 @@
         return self._fixupRet(className, methodName, ret)
 
 
+def Host_fenceNode_Ret(ret):
+    """
+    Only 'power' and 'operationStatus' should be part of return value if they
+    are not None
+    """
+    result = {}
+    for key in ('power', 'operationStatus'):
+        val = ret.get(key)
+        if val is not None:
+            result[key] = val
+    return result
+
+
 def Host_getCapabilities_Ret(server_address, ret):
     """
     We need to add additional information to getCaps as it is done for xmlrpc.
@@ -375,7 +388,7 @@
     'ConnectionRefs_acquire': {'ret': 'results'},
     'ConnectionRefs_release': {'ret': 'results'},
     'ConnectionRefs_statuses': {'ret': 'connectionslist'},
-    'Host_fenceNode': {'ret': 'power'},
+    'Host_fenceNode': {'ret': Host_fenceNode_Ret},
     'Host_getAllTasksInfo': {'ret': 'allTasksInfo'},
     'Host_getAllTasksStatuses': {'ret': 'allTasksStatus'},
     'Host_getCapabilities': {'ret': Host_getCapabilities_Ret},
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 426d28e..19dc5d1 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -271,9 +271,9 @@
 {'enum': 'FenceNodeAction', 'data': ['status', 'on', 'off', 'reboot']}
 
 ##
-# @FenceNodeResult:
+# @FenceNodePowerStatusResult:
 #
-# For 'status' action, the result is the power status of the host
+# The host power status as a result of 'status' action.
 #
 # @on:       The remote host is powered on
 #
@@ -282,8 +282,14 @@
 # @unknown:  The power status is not known
 #
 # Since: 4.10.0
+##
+{'enum': 'FenceNodePowerStatusResult', 'data': ['on', 'off', 'unknown']}
+
+##
+# @FenceNodeOperationStatusResult:
 #
-# For 'on', 'off' and 'reboot', the result is status of fence script execution
+# Status of fence script execution as a result of 'on', 'off' and 'reboot'
+# actions.
 #
 # @initiated:   Fence script was executed
 #
@@ -291,8 +297,24 @@
 #
 # Since: 4.16.0
 ##
-{'enum': 'FenceNodeResult', 'data': ['on', 'off', 'unknown', 'initiated',
-                                     'skipped']}
+{'enum': 'FenceNodeOperationStatusResult', 'data': ['initiated', 'skipped']}
+
+##
+# @FenceNodeResult:
+#
+# Result of fenceNode command.
+#
+# @power:           #optional power status of host as a result of 'status'
+#                   action
+# Since: 4.10.0
+#
+# @operationStatus: #optional status of fence action executions for 'on',
+#                   'off' and 'reboot' actions
+# Since: 4.16.0
+##
+{'type': 'FenceNodeResult',
+ 'data': {'*power': 'FenceNodePowerStatusResult',
+          '*operationStatus': 'FenceNodeOperationStatusResult'}}
 
 ##
 # @HostIdMap:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib39744828d56de2ec0bc6406d7dcfa116a7ec8d8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mperina at redhat.com>


More information about the vdsm-patches mailing list