Michael Schmidt
2015-04-06 17:08:28 UTC
Hi all,
While working with the Python bindings and attempting to add tags to
logical volume lvm_vg_write seems not to be called. This means if add_tag
is called and the virtual group handle is closed the tags disappear. The
action in _liblvm_lvm_vg_add_tag solves this by calling lvm_vg_write on the
handle itself. Since the lv handle does not seem to have access to it's vg
handle I added a method to the vg just to trigger a write:
--- liblvm.c 2015-04-06 11:55:01.972332429 -0500
+++ liblvm_python.c 2015-04-06 11:47:27.989632725 -0500
@@ -1202,6 +1202,23 @@
return pytuple;
}
+static PyObject *_liblvm_lvm_vg_write(vgobject *self)
+{
+ VG_VALID(self);
+
+ if (lvm_vg_write(self->vg) == -1)
+ goto error;
+
+ return Py_None;
+
+error:
+ PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
+
+ Py_INCREF(Py_None);
+ return NULL;
+}
+
+
typedef lv_t (*lv_fetch_by_N)(vg_t vg, const char *id);
typedef pv_t (*pv_fetch_by_N)(vg_t vg, const char *id);
@@ -1854,6 +1871,7 @@
{ "createLvLinear",
(PyCFunction)_liblvm_lvm_vg_create_lv_linear, METH_VARARGS },
{ "createLvThinpool",
(PyCFunction)_liblvm_lvm_vg_create_lv_thinpool, METH_VARARGS },
{ "createLvThin", (PyCFunction)_liblvm_lvm_vg_create_lv_thin,
METH_VARARGS },
+ { "write", (PyCFunction)_liblvm_lvm_vg_write, METH_VARARGS },
{ NULL, NULL } /* sentinel */
};
My question is: is there a better way to accomplish this?
Thanks,
Mike
While working with the Python bindings and attempting to add tags to
logical volume lvm_vg_write seems not to be called. This means if add_tag
is called and the virtual group handle is closed the tags disappear. The
action in _liblvm_lvm_vg_add_tag solves this by calling lvm_vg_write on the
handle itself. Since the lv handle does not seem to have access to it's vg
handle I added a method to the vg just to trigger a write:
--- liblvm.c 2015-04-06 11:55:01.972332429 -0500
+++ liblvm_python.c 2015-04-06 11:47:27.989632725 -0500
@@ -1202,6 +1202,23 @@
return pytuple;
}
+static PyObject *_liblvm_lvm_vg_write(vgobject *self)
+{
+ VG_VALID(self);
+
+ if (lvm_vg_write(self->vg) == -1)
+ goto error;
+
+ return Py_None;
+
+error:
+ PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
+
+ Py_INCREF(Py_None);
+ return NULL;
+}
+
+
typedef lv_t (*lv_fetch_by_N)(vg_t vg, const char *id);
typedef pv_t (*pv_fetch_by_N)(vg_t vg, const char *id);
@@ -1854,6 +1871,7 @@
{ "createLvLinear",
(PyCFunction)_liblvm_lvm_vg_create_lv_linear, METH_VARARGS },
{ "createLvThinpool",
(PyCFunction)_liblvm_lvm_vg_create_lv_thinpool, METH_VARARGS },
{ "createLvThin", (PyCFunction)_liblvm_lvm_vg_create_lv_thin,
METH_VARARGS },
+ { "write", (PyCFunction)_liblvm_lvm_vg_write, METH_VARARGS },
{ NULL, NULL } /* sentinel */
};
My question is: is there a better way to accomplish this?
Thanks,
Mike
--
Michael T Schmidt | schmidmt.com | duality.io
Michael T Schmidt | schmidmt.com | duality.io