Commit 8df68465 by Stéphane Graber

python3: Don't require a template name

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 0d6b9aea
...@@ -733,7 +733,7 @@ Container_create(Container *self, PyObject *args, PyObject *kwds) ...@@ -733,7 +733,7 @@ Container_create(Container *self, PyObject *args, PyObject *kwds)
int i = 0; int i = 0;
static char *kwlist[] = {"template", "flags", "args", NULL}; 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)) &template_name, &flags, &vargs))
return NULL; return NULL;
......
...@@ -201,11 +201,11 @@ class Container(_lxc.Container): ...@@ -201,11 +201,11 @@ class Container(_lxc.Container):
return _lxc.Container.set_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. 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 "flags" (optional) is an integer representing the optional
create flags to be passed. create flags to be passed.
...@@ -222,8 +222,13 @@ class Container(_lxc.Container): ...@@ -222,8 +222,13 @@ class Container(_lxc.Container):
else: else:
template_args = args template_args = args
if template:
return _lxc.Container.create(self, template=template, return _lxc.Container.create(self, template=template,
flags=flags, args=tuple(template_args)) 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, def clone(self, newname, config_path=None, flags=0, bdevtype=None,
bdevdata=None, newsize=0, hookargs=()): bdevdata=None, newsize=0, hookargs=()):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment