These helpers will be used to convert incoming parameters to
JSON-compatible types.

Signed-off-by: Michael Hanselmann <[email protected]>
---
 lib/build/rpc_definitions.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/build/rpc_definitions.py b/lib/build/rpc_definitions.py
index e2bc9f5..0239594 100644
--- a/lib/build/rpc_definitions.py
+++ b/lib/build/rpc_definitions.py
@@ -34,6 +34,14 @@ TMO_1DAY = 86400
 SINGLE = "single-node"
 MULTI = "multi-node"
 
+OBJECT_TO_DICT = "%s.ToDict()"
+OBJECT_LIST_TO_DICT = "map(lambda d: d.ToDict(), %s)"
+INST_TO_DICT = "self._InstDict(%s)"
+
+NODE_TO_DISK_DICT = \
+  ("dict((name, %s) for name, disks in %%s.items())" %
+   (OBJECT_LIST_TO_DICT % "disks"))
+
 CALLS = {
   "RpcClientDefault": [
     ],
-- 
1.7.6

Reply via email to