From 227e22e876728b02e1be56c7325ad015085bfc70 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Tue, 10 Jun 2014 12:08:20 -0400 Subject: [PATCH] Don't require a template name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Chuck Short Acked-by: Stéphane Graber --- lxc.c | 2 +- lxc/__init__.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lxc.c b/lxc.c index e53e792..6fb5f43 100644 --- a/lxc.c +++ b/lxc.c @@ -729,7 +729,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; diff --git a/lxc/__init__.py b/lxc/__init__.py index 45d139d..47b25b8 100644 --- a/lxc/__init__.py +++ b/lxc/__init__.py @@ -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=()):