Commit dd6d2d09 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rpc: Add support for resolver options callback

This adds support for a callback returning name resolver options. This
is required for powercycling offline nodes. While it would be possible
to implement this using a separate RPC client class, doing so would
require some code duplication with the standard “RpcRunner” class.

The callback can generate the options based on the call arguments.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent f863d7aa
......@@ -41,7 +41,7 @@ _SINGLE = "single-node"
_MULTI = "multi-node"
#: Expected length of a rpc definition
def _WritePreamble(sw):
......@@ -125,7 +125,7 @@ def _WriteBaseClass(sw, clsname, calls):
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:
for (name, kind, _, timeout, args, _, _, desc) in calls:
funcargs = ["self"]
if kind == _SINGLE:
......@@ -443,13 +443,19 @@ class _RpcClientBase:
"""Entry point for automatically generated RPC wrappers.
(procedure, _, timeout, argdefs, prep_fn, postproc_fn, _) = cdef
(procedure, _, resolver_opts, timeout, argdefs,
prep_fn, postproc_fn, _) = cdef
if callable(timeout):
read_timeout = timeout(args)
read_timeout = timeout
if callable(resolver_opts):
req_resolver_opts = resolver_opts(args)
req_resolver_opts = resolver_opts
enc_args = map(self._encoder, zip(map(compat.snd, argdefs), args))
if prep_fn is None:
# for a no-op prep_fn, we serialise the body once, and then we
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment