mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-07 11:39:04 +00:00
add bdevtype to lxc create procedure
Signed-off-by: Bieliaievskyi Sergey magelan09@gmail.com
This commit is contained in:
parent
3b6aebceaf
commit
d1dd911376
@ -801,11 +801,11 @@ Container_create(Container *self, PyObject *args, PyObject *kwds)
|
|||||||
char** create_args = {NULL};
|
char** create_args = {NULL};
|
||||||
PyObject *retval = NULL;
|
PyObject *retval = NULL;
|
||||||
PyObject *vargs = NULL;
|
PyObject *vargs = NULL;
|
||||||
|
char *bdevtype = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
static char *kwlist[] = {"template", "flags", "args", NULL};
|
static char *kwlist[] = {"template", "flags", "bdevtype", "args", NULL};
|
||||||
|
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|sisO", kwlist,
|
||||||
if (! PyArg_ParseTupleAndKeywords(args, kwds, "|siO", kwlist,
|
&template_name, &flags, &bdevtype, &vargs))
|
||||||
&template_name, &flags, &vargs))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (vargs) {
|
if (vargs) {
|
||||||
@ -821,7 +821,7 @@ Container_create(Container *self, PyObject *args, PyObject *kwds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->container->create(self->container, template_name, NULL, NULL,
|
if (self->container->create(self->container, template_name, bdevtype, NULL,
|
||||||
flags, create_args))
|
flags, create_args))
|
||||||
retval = Py_True;
|
retval = Py_True;
|
||||||
else
|
else
|
||||||
|
@ -205,7 +205,7 @@ 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=None, flags=0, args=()):
|
def create(self, template=None, flags=0, args=(), bdevtype=None):
|
||||||
"""
|
"""
|
||||||
Create a new rootfs for the container.
|
Create a new rootfs for the container.
|
||||||
|
|
||||||
@ -217,22 +217,19 @@ class Container(_lxc.Container):
|
|||||||
"args" (optional) is a tuple of arguments to pass to the
|
"args" (optional) is a tuple of arguments to pass to the
|
||||||
template. It can also be provided as a dict.
|
template. It can also be provided as a dict.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict):
|
||||||
template_args = []
|
tmp_args = []
|
||||||
for item in args.items():
|
for item in args.items():
|
||||||
template_args.append("--%s" % item[0])
|
tmp_args.append("--%s" % item[0])
|
||||||
template_args.append("%s" % item[1])
|
tmp_args.append("%s" % item[1])
|
||||||
else:
|
template_args = {}
|
||||||
template_args = args
|
|
||||||
|
|
||||||
if template:
|
if template:
|
||||||
return _lxc.Container.create(self, template=template,
|
template_args['template'] = template
|
||||||
flags=flags,
|
template_args['flags'] = flags
|
||||||
args=tuple(template_args))
|
template_args['args'] = tuple(tmp_args)
|
||||||
else:
|
if bdevtype:
|
||||||
return _lxc.Container.create(self, flags=flags,
|
template_args['bdevtype'] = bdevtype
|
||||||
args=tuple(template_args))
|
return _lxc.Container.create(self, **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=()):
|
||||||
|
Loading…
Reference in New Issue
Block a user