Skip to content

Commit

Permalink
python3: Don't require a template name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stgraber committed Jun 4, 2014
1 parent 8db55a6 commit 3a49134
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/python-lxc/lxc.c
Expand Up @@ -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;

Expand Down
13 changes: 9 additions & 4 deletions src/python-lxc/lxc/__init__.py
Expand Up @@ -201,11 +201,11 @@ def append_config_item(self, key, value):

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.
Expand All @@ -222,8 +222,13 @@ def create(self, template, flags=0, args=()):
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=()):
Expand Down

0 comments on commit 3a49134

Please sign in to comment.