Revision c2dc025a
b/lib/rpc.py | ||
---|---|---|
710 | 710 |
"""RPC wrappers for L{config}. |
711 | 711 |
|
712 | 712 |
""" |
713 |
def __init__(self, context, address_list): |
|
713 |
def __init__(self, context, address_list, _req_process_fn=None, |
|
714 |
_getents=None): |
|
714 | 715 |
"""Initializes this class. |
715 | 716 |
|
716 | 717 |
""" |
... | ... | |
725 | 726 |
# Caller provided an address list |
726 | 727 |
resolver = _StaticResolver(address_list) |
727 | 728 |
|
728 |
_RpcClientBase.__init__(self, resolver, _ENCODERS.get, |
|
729 |
lock_monitor_cb=lock_monitor_cb) |
|
729 |
encoders = _ENCODERS.copy() |
|
730 |
|
|
731 |
encoders.update({ |
|
732 |
rpc_defs.ED_FILE_DETAILS: compat.partial(_PrepareFileUpload, _getents), |
|
733 |
}) |
|
734 |
|
|
735 |
_RpcClientBase.__init__(self, resolver, encoders.get, |
|
736 |
lock_monitor_cb=lock_monitor_cb, |
|
737 |
_req_process_fn=_req_process_fn) |
|
730 | 738 |
_generated_rpc.RpcClientConfig.__init__(self) |
b/test/ganeti.rpc_unittest.py | ||
---|---|---|
716 | 716 |
req.resp_body = serializer.DumpJson((True, None)) |
717 | 717 |
|
718 | 718 |
http_proc = _FakeRequestProcessor(_VerifyRequest) |
719 |
cfg = _FakeConfigForRpcRunner() |
|
720 |
runner = rpc.RpcRunner(cfg, None, _req_process_fn=http_proc, |
|
721 |
_getents=mocks.FakeGetentResolver) |
|
719 |
|
|
720 |
std_runner = rpc.RpcRunner(_FakeConfigForRpcRunner(), None, |
|
721 |
_req_process_fn=http_proc, |
|
722 |
_getents=mocks.FakeGetentResolver) |
|
723 |
|
|
724 |
cfg_runner = rpc.ConfigRunner(None, ["192.0.2.13"], |
|
725 |
_req_process_fn=http_proc, |
|
726 |
_getents=mocks.FakeGetentResolver) |
|
722 | 727 |
|
723 | 728 |
nodes = [ |
724 | 729 |
"node1.example.com", |
725 | 730 |
] |
726 | 731 |
|
727 |
result = runner.call_upload_file(nodes, tmpfile.name) |
|
728 |
self.assertEqual(len(result), len(nodes)) |
|
729 |
for (idx, (node, res)) in enumerate(result.items()): |
|
730 |
self.assertFalse(res.fail_msg) |
|
732 |
for runner in [std_runner, cfg_runner]: |
|
733 |
result = runner.call_upload_file(nodes, tmpfile.name) |
|
734 |
self.assertEqual(len(result), len(nodes)) |
|
735 |
for (idx, (node, res)) in enumerate(result.items()): |
|
736 |
self.assertFalse(res.fail_msg) |
|
731 | 737 |
|
732 | 738 |
|
733 | 739 |
if __name__ == "__main__": |
Also available in: Unified diff