mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 15:05:16 +00:00
[1676] Basics of the rpc_call in python
Successful case. Small fixes of the tests.
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from isc.cc import Session
|
from isc.cc import Session
|
||||||
|
from isc.cc.proto_defs import *
|
||||||
from isc.config.config_data import ConfigData, MultiConfigData, BIND10_CONFIG_DATA_VERSION
|
from isc.config.config_data import ConfigData, MultiConfigData, BIND10_CONFIG_DATA_VERSION
|
||||||
import isc.config.module_spec
|
import isc.config.module_spec
|
||||||
import isc
|
import isc
|
||||||
@@ -474,6 +475,16 @@ class ModuleCCSession(ConfigData):
|
|||||||
except isc.cc.SessionTimeout:
|
except isc.cc.SessionTimeout:
|
||||||
raise ModuleCCSessionError("CC Session timeout waiting for configuration manager")
|
raise ModuleCCSessionError("CC Session timeout waiting for configuration manager")
|
||||||
|
|
||||||
|
def rpc_call(self, command, group, instance=CC_INSTANCE_WILDCARD,
|
||||||
|
to=CC_TO_WILDCARD, **params):
|
||||||
|
cmd = create_command(command, params)
|
||||||
|
seq = self._session.group_sendmsg(cmd, group, instance=instance,
|
||||||
|
to=to, want_answer=True)
|
||||||
|
# For non-blocking, we'll have rpc_call_async (once the nonblock actualy
|
||||||
|
# works)
|
||||||
|
reply, rheaders = self._session.group_recvmsg(nonblock=False, seq=seq)
|
||||||
|
code, value = parse_answer(reply)
|
||||||
|
return value
|
||||||
|
|
||||||
class UIModuleCCSession(MultiConfigData):
|
class UIModuleCCSession(MultiConfigData):
|
||||||
"""This class is used in a configuration user interface. It contains
|
"""This class is used in a configuration user interface. It contains
|
||||||
|
@@ -299,13 +299,13 @@ class TestModuleCCSession(unittest.TestCase):
|
|||||||
fake_session.message_queue = [
|
fake_session.message_queue = [
|
||||||
["Spec1", None, {"result": [0, {"Hello": "a"}]}, False]
|
["Spec1", None, {"result": [0, {"Hello": "a"}]}, False]
|
||||||
]
|
]
|
||||||
result = mccs.rpc_call("Spec2", "*", "test", param1="Param 1",
|
result = mccs.rpc_call("test", "Spec2", param1="Param 1",
|
||||||
param2="Param 2")
|
param2="Param 2")
|
||||||
self.assertEqual([
|
self.assertEqual([
|
||||||
["Spec2", "*", {"command": ["test", {
|
["Spec2", "*", {"command": ["test", {
|
||||||
"param1": "Param 1",
|
"param1": "Param 1",
|
||||||
"param2": "Param 2"
|
"param2": "Param 2"
|
||||||
}]}]
|
}]}, True]
|
||||||
], fake_session.message_queue)
|
], fake_session.message_queue)
|
||||||
self.assertEqual({"Hello": "a"}, result)
|
self.assertEqual({"Hello": "a"}, result)
|
||||||
|
|
||||||
|
@@ -68,8 +68,9 @@ class FakeModuleCCSession:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def group_sendmsg(self, msg, channel, target=None, want_answer=False):
|
def group_sendmsg(self, msg, group, instance=None, to=None,
|
||||||
self.message_queue.append([ channel, target, msg, want_answer ])
|
want_answer=False):
|
||||||
|
self.message_queue.append([ group, instance, msg, want_answer ])
|
||||||
return 42
|
return 42
|
||||||
|
|
||||||
def group_reply(self, env, msg):
|
def group_reply(self, env, msg):
|
||||||
|
Reference in New Issue
Block a user