[linux-lvm] [PATCH 2/6] python-lvm: A start at a python-lvm test framework
Andy Grover
agrover at redhat.com
Fri Sep 14 17:54:40 UTC 2012
Needs a lot of work, but it's a start.
Signed-off-by: Andy Grover <agrover at redhat.com>
---
liblvm/python/test.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 liblvm/python/test.py
diff --git a/liblvm/python/test.py b/liblvm/python/test.py
new file mode 100644
index 0000000..62ab74e
--- /dev/null
+++ b/liblvm/python/test.py
@@ -0,0 +1,42 @@
+#-----------------------------
+#Python example code:
+#-----------------------------
+
+import liblvm
+
+# create a new LVM instance
+lvm = liblvm.Liblvm()
+
+# open a VG handle in write mode for 'myvg'
+vg = lvm.vgOpen('myvg','w')
+
+# remove a new LV (lv_foobar)
+lv = vg.createLvLinear('lv_foobar',100000)
+
+# print the uuid for the newly created LV
+print lv.getUuid()
+
+#print the size.
+print lv.getSize()
+
+# Add a tag to it.
+lv.addTag("my_fance_tag")
+
+# Print all tags.
+print lv.getTags()
+
+# Try to deactivate
+try:
+ lv.deactivate()
+except liblvm.LibLVMError:
+ print "lets retry.."
+ lv.deactivate()
+
+# remove
+lv.remove()
+
+# close VG handle
+vg.close()
+
+# close LVM handle
+lvm.close()
--
1.7.1
More information about the linux-lvm
mailing list