Support newstyple rbd commangd output
[ganeti-local] / autotools / build-rpc
index 222619f..a862d94 100755 (executable)
@@ -40,6 +40,9 @@ from ganeti import build
 _SINGLE = "single-node"
 _MULTI = "multi-node"
 
+#: Expected length of a rpc definition
+_RPC_DEF_LEN = 8
+
 
 def _WritePreamble(sw):
   """Writes a preamble for the RPC wrapper output.
@@ -117,7 +120,12 @@ def _WriteBaseClass(sw, clsname, calls):
     sw.Write("_CALLS = rpc_defs.CALLS[%r]", clsname)
     sw.Write("")
 
-    for (name, kind, timeout, args, _, desc) in calls:
+    for v in calls:
+      if len(v) != _RPC_DEF_LEN:
+        raise ValueError("Procedure %s has only %d elements, expected %d" %
+                         (v[0], len(v), _RPC_DEF_LEN))
+
+    for (name, kind, _, timeout, args, _, _, desc) in calls:
       funcargs = ["self"]
 
       if kind == _SINGLE:
@@ -187,6 +195,12 @@ def main():
     assert module.SINGLE == _SINGLE
     assert module.MULTI == _MULTI
 
+    dups = utils.FindDuplicates(itertools.chain(*map(lambda value: value.keys(),
+                                                     module.CALLS.values())))
+    if dups:
+      raise Exception("Found duplicate RPC definitions for '%s'" %
+                      utils.CommaJoin(sorted(dups)))
+
     for (clsname, calls) in module.CALLS.items():
       _WriteBaseClass(sw, clsname, calls.values())