BIND 10 trac2930, updated. 143264e9d77c446e9f5d9f2611198bb73de82243 [2930] Sending notifications, python part
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue May 21 14:15:39 UTC 2013
The branch, trac2930 has been updated
via 143264e9d77c446e9f5d9f2611198bb73de82243 (commit)
from f3cd2b49392a4883751e2dbce2d8677e46d1f167 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 143264e9d77c446e9f5d9f2611198bb73de82243
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue May 21 16:15:09 2013 +0200
[2930] Sending notifications, python part
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/config/ccsession.py | 22 +++++++++++++++++++++
src/lib/python/isc/config/tests/ccsession_test.py | 12 +++++++++++
2 files changed, 34 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py
index e801309..8b824b8 100644
--- a/src/lib/python/isc/config/ccsession.py
+++ b/src/lib/python/isc/config/ccsession.py
@@ -539,6 +539,28 @@ class ModuleCCSession(ConfigData):
raise RPCError(code, value)
return value
+ def notify(self, notification_group, event_name, params=None):
+ """
+ Send a notification about an event to a group of recipients.
+
+ Params:
+ - notification_group: This indirectly specifies which recipients get
+ the notification. Only the ones that register callback for the same
+ gorup get it.
+ - event_name: The name of the notification.
+ - params: Additional description of the event.
+ Return: Nothing
+ """
+ notification = [event_name]
+ if params is not None:
+ notification.append(params)
+ self._session.group_sendmsg({'notification': notification},
+ CC_GROUP_NOTIFICATION_PREFIX +
+ notification_group,
+ instance=CC_INSTANCE_WILDCARD,
+ to=CC_TO_WILDCARD,
+ want_answer=False)
+
class UIModuleCCSession(MultiConfigData):
"""This class is used in a configuration user interface. It contains
specific functions for getting, displaying, and sending
diff --git a/src/lib/python/isc/config/tests/ccsession_test.py b/src/lib/python/isc/config/tests/ccsession_test.py
index 2a2d790..f7d014d 100644
--- a/src/lib/python/isc/config/tests/ccsession_test.py
+++ b/src/lib/python/isc/config/tests/ccsession_test.py
@@ -350,6 +350,18 @@ class TestModuleCCSession(unittest.TestCase):
self.assertRaises(RPCRecipientMissing, self.rpc_check,
{"result": [-1, "Error"]})
+ def test_notify(self):
+ """
+ Test the sent notification has the right format.
+ """
+ fake_session = FakeModuleCCSession()
+ mccs = self.create_session("spec1.spec", None, None, fake_session)
+ mccs.notify("group", "event", {"param": True})
+ self.assertEqual([
+ ["notifications/group", "*", {"notification": ["event", {
+ "param": True
+ }]}, False]], fake_session.message_queue)
+
def my_config_handler_ok(self, new_config):
return isc.config.ccsession.create_answer(0)
More information about the bind10-changes
mailing list