mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
python-lvm: Add addl. PV create arguments
Added overloaded PV create arguments with defaults for PV creation. Addresses bug: https://bugzilla.redhat.com/show_bug.cgi?id=880395 Signed-off-by: Tony Asleson <tasleson@redhat.com>
This commit is contained in:
parent
04304ba735
commit
531d85a0ee
@ -23,6 +23,7 @@
|
||||
|
||||
#include <Python.h>
|
||||
#include "lvm2app.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static lvm_t _libh;
|
||||
|
||||
@ -317,24 +318,62 @@ static PyObject *_liblvm_lvm_pv_remove(PyObject *self, PyObject *arg)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static int _set_pv_numeric_prop(pv_create_params_t pv_params, const char *name,
|
||||
unsigned long long value)
|
||||
{
|
||||
struct lvm_property_value prop_value;
|
||||
prop_value.is_integer = 1;
|
||||
prop_value.value.integer = value;
|
||||
|
||||
return lvm_pv_params_set_property(pv_params, name, &prop_value);
|
||||
}
|
||||
|
||||
#define SET_PV_PROP(params, name, value) \
|
||||
do { \
|
||||
if (_set_pv_numeric_prop(params, name, value) == -1) \
|
||||
goto error; \
|
||||
} while(0)\
|
||||
|
||||
static PyObject *_liblvm_lvm_pv_create(PyObject *self, PyObject *arg)
|
||||
{
|
||||
const char *pv_name;
|
||||
unsigned long long size;
|
||||
unsigned long long size = 0;
|
||||
unsigned long long pvmetadatacopies = DEFAULT_PVMETADATACOPIES;
|
||||
unsigned long long pvmetadatasize = DEFAULT_PVMETADATASIZE;
|
||||
unsigned long long data_alignment = 0;
|
||||
unsigned long long data_alignment_offset = 0;
|
||||
unsigned long long zero = 1;
|
||||
pv_create_params_t pv_params = NULL;
|
||||
|
||||
LVM_VALID(NULL);
|
||||
|
||||
if (!PyArg_ParseTuple(arg, "sK", &pv_name, &size))
|
||||
if (!PyArg_ParseTuple(arg, "s|KKKKKK", &pv_name, &size, &pvmetadatacopies,
|
||||
&pvmetadatasize, &data_alignment,
|
||||
&data_alignment_offset, &zero))
|
||||
return NULL;
|
||||
|
||||
if (lvm_pv_create(_libh, pv_name, size) == -1) {
|
||||
PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
|
||||
return NULL;
|
||||
pv_params = lvm_pv_params_create(_libh, pv_name);
|
||||
if (!pv_params) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
SET_PV_PROP(pv_params, "size", size);
|
||||
SET_PV_PROP(pv_params, "pvmetadatacopies", pvmetadatacopies);
|
||||
SET_PV_PROP(pv_params, "pvmetadatasize", pvmetadatasize);
|
||||
SET_PV_PROP(pv_params, "data_alignment", data_alignment);
|
||||
SET_PV_PROP(pv_params, "data_alignment_offset", data_alignment_offset);
|
||||
SET_PV_PROP(pv_params, "zero", zero);
|
||||
|
||||
if (lvm_pv_create_adv(pv_params)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
||||
return Py_None;
|
||||
|
||||
error:
|
||||
PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *_liblvm_lvm_percent_to_float(PyObject *self, PyObject *arg)
|
||||
|
Loading…
Reference in New Issue
Block a user