[lxc-devel] [PATCH] python3: Add missing get_running_config_item binding

Stéphane Graber stgraber at ubuntu.com
Thu Feb 13 16:55:47 UTC 2014


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/python-lxc/lxc.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c
index 9fdc27f..f7ab092 100644
--- a/src/python-lxc/lxc.c
+++ b/src/python-lxc/lxc.c
@@ -1007,6 +1007,30 @@ Container_get_ips(Container *self, PyObject *args, PyObject *kwds)
 }
 
 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)
 {
     static char *kwlist[] = {"path", NULL};
@@ -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"
-- 
1.9.rc1



More information about the lxc-devel mailing list