diff --git a/autotools/build-rpc b/autotools/build-rpc
index a804911895d5aeba67ccbc7aa8f070bb74f0ebaa..0e8d5b93e07c01663a6834dcd6cf23d2eea53684 100755
--- a/autotools/build-rpc
+++ b/autotools/build-rpc
@@ -52,6 +52,8 @@ def _WritePreamble(sw):
   sw.Write("")
   sw.Write("\"\"\"")
   sw.Write("")
+  sw.Write("from ganeti import rpc_defs")
+  sw.Write("")
 
 
 def _WrapCode(line):
@@ -112,6 +114,9 @@ def _WriteBaseClass(sw, clsname, calls):
       sw.Write("pass")
       return
 
+    sw.Write("_CALLS = rpc_defs.CALLS[%r]", clsname)
+    sw.Write("")
+
     for (name, kind, timeout, args, postproc, desc) in calls:
       funcargs = ["self"]
 
@@ -127,6 +132,8 @@ def _WriteBaseClass(sw, clsname, calls):
       assert "read_timeout" not in funcargs
       funcargs.append("read_timeout=%s" % timeout)
 
+      funcargs.append("_def=_CALLS[%r]" % name)
+
       funcdef = "def call_%s(%s):" % (name, utils.CommaJoin(funcargs))
       for line in _WrapCode(funcdef):
         sw.Write(line)
@@ -143,18 +150,15 @@ def _WriteBaseClass(sw, clsname, calls):
 
         if postproc:
           buf.write("%s(" % postproc)
-        buf.write("self._Call(")
+        buf.write("self._Call(_def, ")
         if kind == _SINGLE:
           buf.write("[node]")
         else:
           buf.write("node_list")
 
-        buf.write(", \"%s\", read_timeout, [%s], [%s])" %
-                  (name,
-                   # Argument definitions
-                   utils.CommaJoin(map(compat.snd, args)),
-                   # Function arguments
-                   utils.CommaJoin(map(compat.fst, args))))
+        buf.write(", read_timeout, [%s])" %
+                  # Function arguments
+                  utils.CommaJoin(map(compat.fst, args)))
 
         if kind == _SINGLE:
           buf.write("[node]")
diff --git a/lib/rpc.py b/lib/rpc.py
index c117f0cfa56cfe825ba3f41ffad38aa36406e18c..74c924f408cbb6b7f5bbfe8f16e50c00bf648851 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -430,13 +430,14 @@ class _RpcClientBase:
     else:
       return encoder_fn(argkind)(value)
 
-  def _Call(self, node_list, procedure, timeout, argdefs, args):
+  def _Call(self, cdef, node_list, timeout, args):
     """Entry point for automatically generated RPC wrappers.
 
     """
-    assert len(args) == len(argdefs), "Wrong number of arguments"
+    (procedure, _, _, argdefs, _, _) = cdef
 
-    body = serializer.DumpJson(map(self._encoder, zip(argdefs, args)),
+    body = serializer.DumpJson(map(self._encoder,
+                                   zip(map(compat.snd, argdefs), args)),
                                indent=False)
 
     return self._proc(node_list, procedure, body, read_timeout=timeout)