From: Stéphane Graber Date: Thu, 13 Feb 2014 15:59:19 +0000 (-0500) Subject: python3: Add missing get_running_config_item binding X-Git-Tag: lxc-1.0.0.rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87d8dfe56c7b2af3f598ba886ba426af2b50b5b2;p=thirdparty%2Flxc.git python3: Add missing get_running_config_item binding Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c index 9fdc27f49..f7ab09222 100644 --- a/src/python-lxc/lxc.c +++ b/src/python-lxc/lxc.c @@ -1006,6 +1006,30 @@ Container_get_ips(Container *self, PyObject *args, PyObject *kwds) return ret; } +static PyObject * +Container_get_running_config_item(Container *self, PyObject *args, + PyObject *kwds) +{ + static char *kwlist[] = {"key", NULL}; + char* key = NULL; + char* value = NULL; + PyObject *ret = NULL; + + if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist, + &key)) + return NULL; + + value = self->container->get_running_config_item(self->container, key); + + if (!value) + Py_RETURN_NONE; + + ret = PyUnicode_FromString(value); + free(value); + return ret; +} + + static PyObject * Container_load_config(Container *self, PyObject *args, PyObject *kwds) { @@ -1537,6 +1561,12 @@ static PyMethodDef Container_methods[] = { "\n" "Get a tuple of IPs for the container." }, + {"get_running_config_item", (PyCFunction)Container_get_running_config_item, + METH_VARARGS|METH_KEYWORDS, + "get_running_config_item(key) -> string\n" + "\n" + "Get the runtime value of a config key." + }, {"load_config", (PyCFunction)Container_load_config, METH_VARARGS|METH_KEYWORDS, "load_config(path = DEFAULT) -> boolean\n"