* [linux-lvm] Tagging LVs with Python Bindings
@ 2015-04-06 17:08 Michael Schmidt
2015-04-07 20:54 ` Tony Asleson
0 siblings, 1 reply; 4+ messages in thread
From: Michael Schmidt @ 2015-04-06 17:08 UTC (permalink / raw)
To: linux-lvm
[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]
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
--
Michael T Schmidt | schmidmt.com | duality.io
[-- Attachment #2: Type: text/html, Size: 2391 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-lvm] Tagging LVs with Python Bindings
2015-04-06 17:08 [linux-lvm] Tagging LVs with Python Bindings Michael Schmidt
@ 2015-04-07 20:54 ` Tony Asleson
2015-04-08 15:47 ` Michael Schmidt
0 siblings, 1 reply; 4+ messages in thread
From: Tony Asleson @ 2015-04-07 20:54 UTC (permalink / raw)
To: linux-lvm
On 04/06/2015 12:08 PM, Michael Schmidt wrote:
> 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.
Thanks for reporting this!
> 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:
The python bindings were written with the expectation that the state
changes would be saved automatically. So adding a call for the user to
issue a write on the vg goes against the overall design.
...
> My question is: is there a better way to accomplish this?
In this case we should issue the lvm_vg_write in the add/remove tag
calls for the lv. The lv structure has a pointer to the parent vg in
the python binding.
I submitted a patch which does this and improves the unit test to test
for this.
Any bugzilla submitted for this?
Regards,
Tony
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-lvm] Tagging LVs with Python Bindings
2015-04-07 20:54 ` Tony Asleson
@ 2015-04-08 15:47 ` Michael Schmidt
2015-04-08 17:10 ` Tony Asleson
0 siblings, 1 reply; 4+ messages in thread
From: Michael Schmidt @ 2015-04-08 15:47 UTC (permalink / raw)
To: tasleson, LVM general discussion and development
[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]
Much appreciated. I'll integrated your fix into the build I have.
I looked through Bugzilla and didn't see anything and decided it would be
more straight forward to ask if there was an existing method to solve the
problem before suggesting it was a bug.
-Mike Schmidt
On Tue, Apr 7, 2015 at 3:54 PM, Tony Asleson <tasleson@redhat.com> wrote:
> On 04/06/2015 12:08 PM, Michael Schmidt wrote:
> > 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.
>
> Thanks for reporting this!
>
> > 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:
>
> The python bindings were written with the expectation that the state
> changes would be saved automatically. So adding a call for the user to
> issue a write on the vg goes against the overall design.
>
> ...
>
> > My question is: is there a better way to accomplish this?
>
> In this case we should issue the lvm_vg_write in the add/remove tag
> calls for the lv. The lv structure has a pointer to the parent vg in
> the python binding.
>
> I submitted a patch which does this and improves the unit test to test
> for this.
>
> Any bugzilla submitted for this?
>
> Regards,
> Tony
>
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
>
--
Michael T Schmidt | schmidmt.com | duality.io
[-- Attachment #2: Type: text/html, Size: 2683 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-08 17:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-06 17:08 [linux-lvm] Tagging LVs with Python Bindings Michael Schmidt
2015-04-07 20:54 ` Tony Asleson
2015-04-08 15:47 ` Michael Schmidt
2015-04-08 17:10 ` Tony Asleson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).