diff --git a/python/samba/tests/messaging.py b/python/samba/tests/messaging.py index 5d32d608862..1c5dfe505b6 100644 --- a/python/samba/tests/messaging.py +++ b/python/samba/tests/messaging.py @@ -49,6 +49,10 @@ class MessagingTests(TestCase): x = self.get_context() self.assertTrue(isinstance(x.server_id, server_id)) + def test_add_name(self): + x = self.get_context() + x.irpc_add_name("samba.messaging test") + def test_ping_speed(self): server_ctx = self.get_context((0, 1)) def ping_callback(src, data): diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index f62354b8a02..5c20c186faf 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -241,6 +241,25 @@ static PyObject *py_imessaging_deregister(PyObject *self, PyObject *args, PyObje Py_RETURN_NONE; } +static PyObject *py_irpc_add_name(PyObject *self, PyObject *args, PyObject *kwargs) +{ + imessaging_Object *iface = (imessaging_Object *)self; + char *server_name; + NTSTATUS status; + + if (!PyArg_ParseTuple(args, "s", &server_name)) { + return NULL; + } + + status = irpc_add_name(iface->msg_ctx, server_name); + if (!NT_STATUS_IS_OK(status)) { + PyErr_SetNTSTATUS(status); + return NULL; + } + + Py_RETURN_NONE; +} + static PyObject *py_irpc_servers_byname(PyObject *self, PyObject *args, PyObject *kwargs) { imessaging_Object *iface = (imessaging_Object *)self; @@ -341,10 +360,15 @@ static PyMethodDef py_imessaging_methods[] = { "S.register(callback, msg_type=None) -> msg_type\nRegister a message handler" }, { "deregister", (PyCFunction)py_imessaging_deregister, METH_VARARGS|METH_KEYWORDS, "S.deregister(callback, msg_type) -> None\nDeregister a message handler" }, + { "irpc_add_name", (PyCFunction)py_irpc_add_name, METH_VARARGS, + "S.irpc_add_name(name) -> None\n" + "Add this context to the list of server_id values that " + "are registered for a particular name" }, { "irpc_servers_byname", (PyCFunction)py_irpc_servers_byname, METH_VARARGS, "S.irpc_servers_byname(name) -> list\nGet list of server_id values that are registered for a particular name" }, { "irpc_all_servers", (PyCFunction)py_irpc_all_servers, METH_NOARGS, - "S.irpc_servers_byname() -> list\nGet list of all registered names and the associated server_id values" }, + "S.irpc_all_servers() -> list\n" + "Get list of all registered names and the associated server_id values" }, { NULL, NULL, 0, NULL } };