]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
python3: Don't require a template name
authorStéphane Graber <stgraber@ubuntu.com>
Sun, 25 May 2014 12:36:28 +0000 (14:36 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 3 Jun 2014 15:31:09 +0000 (11:31 -0400)
The template name isn't required, if it's not passed, then create will
simply be asked to create a container without a rootfs.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/python-lxc/lxc.c
src/python-lxc/lxc/__init__.py

index f7ab09222b13e5b40648119b49ea0e27cdee41c7..d436c284625448a1ebcaf32b2f8f4871b8ffb412 100644 (file)
@@ -733,7 +733,7 @@ Container_create(Container *self, PyObject *args, PyObject *kwds)
     int i = 0;
     static char *kwlist[] = {"template", "flags", "args", NULL};
 
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|iO", kwlist,
+    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|siO", kwlist,
                                       &template_name, &flags, &vargs))
         return NULL;
 
index 45d139d71e49331ad544244126a1f773124fa58f..47b25b8e4a6c81a8e7c7ad63b414599a885d9563 100644 (file)
@@ -201,11 +201,11 @@ class Container(_lxc.Container):
 
         return _lxc.Container.set_config_item(self, key, value)
 
-    def create(self, template, flags=0, args=()):
+    def create(self, template=None, flags=0, args=()):
         """
             Create a new rootfs for the container.
 
-            "template" must be a valid template name.
+            "template" if passed must be a valid template name.
 
             "flags" (optional) is an integer representing the optional
             create flags to be passed.
@@ -222,8 +222,13 @@ class Container(_lxc.Container):
         else:
             template_args = args
 
-        return _lxc.Container.create(self, template=template,
-                                     flags=flags, args=tuple(template_args))
+        if template:
+            return _lxc.Container.create(self, template=template,
+                                         flags=flags,
+                                         args=tuple(template_args))
+        else:
+            return _lxc.Container.create(self, flags=flags,
+                                         args=tuple(template_args))
 
     def clone(self, newname, config_path=None, flags=0, bdevtype=None,
               bdevdata=None, newsize=0, hookargs=()):