Skip to contentSkip to conversation

master - python: Make lv addTag/removeTag persistent

PATCH tasleson 1 participant 1 message Apr 10, 2015

lore
Share & tools
lore

tasleson

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2b557b595a52782458b0d217d2ca114c7f8c62c7
Commit:        2b557b595a52782458b0d217d2ca114c7f8c62c7
Parent:        394250ef6759243e59de41dd6cfced544c041c76
Author:        Tony Asleson <[email protected]>
AuthorDate:    Tue Apr 7 15:25:20 2015 -0500
Committer:     Tony Asleson <[email protected]>
CommitterDate: Fri Apr 10 10:38:43 2015 -0500

python: Make lv addTag/removeTag persistent

Added lvm_vg_write in the addTag/removeTag paths to make the changes persist. Added unit test to ensure functionality.

https://bugzilla.redhat.com/show_bug.cgi?id=1210020

---
 python/liblvm.c             |   27 ++++++++----
 test/api/pytest.sh          |    1 +
 test/api/python_lvm_unit.py |   94 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+), 9 deletions(-)
python/liblvm.c +18 -9
index 3828f27..74d65ea 100644
@@ -1444,13 +1444,18 @@ static PyObject *_liblvm_lvm_lv_add_tag(lvobject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "s", &tag))
 		return NULL;
 
-	if (lvm_lv_add_tag(self->lv, tag) == -1) {
-		PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
-		return NULL;
-	}
+	if (lvm_lv_add_tag(self->lv, tag) == -1)
+        goto error;
+
+    if (lvm_vg_write(self->parent_vgobj->vg) == -1)
+		goto error;
 
 	Py_INCREF(Py_None);
 	return Py_None;
+
+error:
+	PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
+	return NULL;
 }
 
 static PyObject *_liblvm_lvm_lv_remove_tag(lvobject *self, PyObject *args)
@@ -1462,14 +1467,18 @@ static PyObject *_liblvm_lvm_lv_remove_tag(lvobject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "s", &tag))
 		return NULL;
 
-	if (lvm_lv_remove_tag(self->lv, tag) == -1) {
-		PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
-		return NULL;
-	}
+	if (lvm_lv_remove_tag(self->lv, tag) == -1)
+        goto error;
 
-	Py_INCREF(Py_None);
+    if (lvm_vg_write(self->parent_vgobj->vg) == -1)
+        goto error;
 
+	Py_INCREF(Py_None);
 	return Py_None;
+
+error:
+	PyErr_SetObject(_LibLVMError, _liblvm_get_last_error());
+	return NULL;
 }
 
 static PyObject *_liblvm_lvm_lv_get_tags(lvobject *self)
test/api/pytest.sh +1 -0
index 36f55fa..00ab051 100644
@@ -45,6 +45,7 @@ export PY_UNIT_PVS=$(cat DEVICES)
 #python_lvm_unit.py -v -f
 
 # Run individual tests for shorter error trace
+python_lvm_unit.py -v TestLvm.test_lv_persistence
 python_lvm_unit.py -v TestLvm.test_config_find_bool
 python_lvm_unit.py -v TestLvm.test_config_override
 python_lvm_unit.py -v TestLvm.test_config_reload
test/api/python_lvm_unit.py +94 -0

100 lines not on this page · raw message