1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

pymessaging: Add support for irpc_add_name

This allows tests to be indirectly added for server_id_db_lookup()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-by: Gary Lockyer <gary@catalyst.net.nz>
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12705
This commit is contained in:
Andrew Bartlett 2017-03-08 14:53:26 +13:00
parent a47a8e41bd
commit 3bd9e5f4ed
2 changed files with 29 additions and 1 deletions

View File

@ -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):

View File

@ -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 }
};