From d565f83f4503810cc5df45615f81237261c6d76e Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 24 Oct 2011 16:32:59 +0200
Subject: [PATCH] rpc_definitions: Add helpers

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

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/build/rpc_definitions.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/build/rpc_definitions.py b/lib/build/rpc_definitions.py
index e2bc9f501..0239594c5 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": [
     ],
-- 
GitLab