Revision f7d9b3aa
b/autotools/build-rpc | ||
---|---|---|
129 | 129 |
|
130 | 130 |
funcargs.extend(map(compat.fst, args)) |
131 | 131 |
|
132 |
assert "read_timeout" not in funcargs |
|
133 |
funcargs.append("read_timeout=%s" % timeout) |
|
134 |
|
|
135 | 132 |
funcargs.append("_def=_CALLS[%r]" % name) |
136 | 133 |
|
137 | 134 |
funcdef = "def call_%s(%s):" % (name, utils.CommaJoin(funcargs)) |
... | ... | |
154 | 151 |
else: |
155 | 152 |
buf.write("node_list") |
156 | 153 |
|
157 |
buf.write(", read_timeout, [%s])" %
|
|
154 |
buf.write(", [%s])" % |
|
158 | 155 |
# Function arguments |
159 | 156 |
utils.CommaJoin(map(compat.fst, args))) |
160 | 157 |
|
b/lib/rpc.py | ||
---|---|---|
430 | 430 |
else: |
431 | 431 |
return encoder_fn(argkind)(value) |
432 | 432 |
|
433 |
def _Call(self, cdef, node_list, timeout, args):
|
|
433 |
def _Call(self, cdef, node_list, args): |
|
434 | 434 |
"""Entry point for automatically generated RPC wrappers. |
435 | 435 |
|
436 | 436 |
""" |
437 |
(procedure, _, _, argdefs, postproc_fn, _) = cdef |
|
437 |
(procedure, _, timeout, argdefs, postproc_fn, _) = cdef |
|
438 |
|
|
439 |
if callable(timeout): |
|
440 |
read_timeout = timeout(args) |
|
441 |
else: |
|
442 |
read_timeout = timeout |
|
438 | 443 |
|
439 | 444 |
body = serializer.DumpJson(map(self._encoder, |
440 | 445 |
zip(map(compat.snd, argdefs), args)), |
441 | 446 |
indent=False) |
442 | 447 |
|
443 |
result = self._proc(node_list, procedure, body, read_timeout=timeout) |
|
448 |
result = self._proc(node_list, procedure, body, read_timeout=read_timeout)
|
|
444 | 449 |
|
445 | 450 |
if postproc_fn: |
446 | 451 |
return postproc_fn(result) |
... | ... | |
620 | 625 |
""" |
621 | 626 |
return self._InstDict(instance, osp=osparams) |
622 | 627 |
|
623 |
# |
|
624 |
# Begin RPC calls |
|
625 |
# |
|
626 |
|
|
627 |
def call_test_delay(self, node_list, duration): # pylint: disable=W0221 |
|
628 |
"""Sleep for a fixed time on given node(s). |
|
629 |
|
|
630 |
This is a multi-node call. |
|
631 |
|
|
632 |
""" |
|
633 |
# TODO: Use callable timeout calculation |
|
634 |
return _generated_rpc.RpcClientDefault.call_test_delay(self, |
|
635 |
node_list, duration, read_timeout=int(duration + 5)) |
|
636 |
|
|
637 | 628 |
|
638 | 629 |
class JobQueueRunner(_RpcClientBase, _generated_rpc.RpcClientJobQueue): |
639 | 630 |
"""RPC wrappers for job queue. |
b/lib/rpc_defs.py | ||
---|---|---|
24 | 24 |
|
25 | 25 |
- Name as string |
26 | 26 |
- L{SINGLE} for single-node calls, L{MULTI} for multi-node |
27 |
- Timeout (e.g. L{TMO_NORMAL}) |
|
27 |
- Timeout (e.g. L{TMO_NORMAL}), or callback receiving all arguments in a |
|
28 |
tuple to calculate timeout |
|
28 | 29 |
- List of arguments as tuples |
29 | 30 |
|
30 | 31 |
- Name as string |
... | ... | |
149 | 150 |
return result |
150 | 151 |
|
151 | 152 |
|
153 |
def _TestDelayTimeout((duration, )): |
|
154 |
"""Calculate timeout for "test_delay" RPC. |
|
155 |
|
|
156 |
""" |
|
157 |
return int(duration + 5) |
|
158 |
|
|
159 |
|
|
152 | 160 |
_FILE_STORAGE_CALLS = [ |
153 | 161 |
("file_storage_dir_create", SINGLE, TMO_FAST, [ |
154 | 162 |
("file_storage_dir", None, "File storage directory"), |
... | ... | |
457 | 465 |
], None, "Call an iallocator on a remote node"), |
458 | 466 |
("test_delay", MULTI, None, [ |
459 | 467 |
("duration", None, None), |
460 |
], None, "Sleep for a fixed time on given node(s)"),
|
|
468 |
], _TestDelayTimeout, "Sleep for a fixed time on given node(s)"),
|
|
461 | 469 |
("hypervisor_validate_params", MULTI, TMO_NORMAL, [ |
462 | 470 |
("hvname", None, "Hypervisor name"), |
463 | 471 |
("hvfull", None, "Parameters to be validated"), |
Also available in: Unified diff