]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
python3: Add (add|remove)_device_node
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 27 Nov 2013 21:57:58 +0000 (16:57 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 27 Nov 2013 22:45:11 +0000 (17:45 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/python-lxc/lxc.c

index 43e571d9d2c748e43f97391ec9c85a330116819c..de02d4b3863021929753730d939869d88f1ba897 100644 (file)
@@ -504,6 +504,25 @@ Container_state(Container *self, void *closure)
 }
 
 /* Container Functions */
+static PyObject *
+Container_add_device_node(Container *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"src_path", "dest_path", NULL};
+    char *src_path = NULL;
+    char *dst_path = NULL;
+
+    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|s", kwlist,
+                                      &src_path, &dst_path))
+        return NULL;
+
+    if (self->container->add_device_node(self->container, src_path,
+                                         dst_path)) {
+        Py_RETURN_TRUE;
+    }
+
+    Py_RETURN_FALSE;
+}
+
 static PyObject *
 Container_attach_and_possibly_wait(Container *self, PyObject *args,
                                    PyObject *kwds, int wait)
@@ -929,6 +948,25 @@ Container_reboot(Container *self, PyObject *args, PyObject *kwds)
     Py_RETURN_FALSE;
 }
 
+static PyObject *
+Container_remove_device_node(Container *self, PyObject *args, PyObject *kwds)
+{
+    static char *kwlist[] = {"src_path", "dest_path", NULL};
+    char *src_path = NULL;
+    char *dst_path = NULL;
+
+    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|s", kwlist,
+                                      &src_path, &dst_path))
+        return NULL;
+
+    if (self->container->remove_device_node(self->container, src_path,
+                                            dst_path)) {
+        Py_RETURN_TRUE;
+    }
+
+    Py_RETURN_FALSE;
+}
+
 static PyObject *
 Container_save_config(Container *self, PyObject *args, PyObject *kwds)
 {
@@ -1139,6 +1177,12 @@ static PyGetSetDef Container_getseters[] = {
 };
 
 static PyMethodDef Container_methods[] = {
+    {"add_device_node", (PyCFunction)Container_add_device_node,
+     METH_VARARGS|METH_KEYWORDS,
+     "add_device_node(src_path, dest_path) -> boolean\n"
+     "\n"
+     "Pass a new device to the container."
+    },
     {"attach", (PyCFunction)Container_attach,
      METH_VARARGS|METH_KEYWORDS,
      "attach(run, payload) -> int\n"
@@ -1244,6 +1288,12 @@ static PyMethodDef Container_methods[] = {
      "\n"
      "Ask the container to reboot."
     },
+    {"remove_device_node", (PyCFunction)Container_remove_device_node,
+     METH_VARARGS|METH_KEYWORDS,
+     "remove_device_node(src_path, dest_path) -> boolean\n"
+     "\n"
+     "Remove a device from the container."
+    },
     {"save_config", (PyCFunction)Container_save_config,
      METH_VARARGS|METH_KEYWORDS,
      "save_config(path = DEFAULT) -> boolean\n"