py-param: Add python interface to get server_role
authorAmitay Isaacs <amitay@gmail.com>
Thu, 10 Nov 2011 04:42:44 +0000 (15:42 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 16 Nov 2011 23:34:09 +0000 (00:34 +0100)
source4/param/pyparam.c

index d5049d7d6602aa507f43310808cf4324140e5f06..e7eb43f28e75da16a12a53f62a541098b8001567 100644 (file)
@@ -255,6 +255,18 @@ static PyObject *py_lp_ctx_services(pytalloc_Object *self)
        return ret;
 }
 
+static PyObject *py_lp_ctx_server_role(pytalloc_Object *self)
+{
+       struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
+       uint32_t role;
+       const char *role_str;
+
+       role = lpcfg_server_role(lp_ctx);
+       role_str = server_role_str(role);
+
+       return PyString_FromString(role_str);
+}
+
 static PyObject *py_lp_dump(PyObject *self, PyObject *args)
 {
        PyObject *py_stream;
@@ -306,6 +318,9 @@ static PyMethodDef py_lp_ctx_methods[] = {
                "S.private_path(name) -> path\n" },
        { "services", (PyCFunction)py_lp_ctx_services, METH_NOARGS,
                "S.services() -> list" },
+       { "server_role", (PyCFunction)py_lp_ctx_server_role, METH_NOARGS,
+               "S.server_role() -> value\n"
+               "Get the server role." },
        { "dump", (PyCFunction)py_lp_dump, METH_VARARGS, 
                "S.dump(stream, show_defaults=False)" },
        { "samdb_url", (PyCFunction)py_samdb_url, METH_NOARGS,