[node-patches] Change in ovirt-node[master]: Add utils.system.LVM(.VG)
rbarry at redhat.com
rbarry at redhat.com
Mon May 12 22:15:20 UTC 2014
Ryan Barry has uploaded a new change for review.
Change subject: Add utils.system.LVM(.VG)
......................................................................
Add utils.system.LVM(.VG)
Add utility classes for accessing LVM attributes
Change-Id: I33008a140c7a74afba794c29ba7acbcec89a53ed
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/utils/system.py
1 file changed, 29 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/06/27606/1
diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index bdc8603..d3bffe1 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -793,7 +793,7 @@
def __getitem__(self, key):
if re.match(r'^(.*?)=', key):
argument = re.match(r'^(.*?)=', key).groups()[0]
- #flags = re.match(r'^.*?=(.*)', key).groups()[0]
+ # flags = re.match(r'^.*?=(.*)', key).groups()[0]
if argument in self.items:
return self.items[argument]
elif key in self.items:
@@ -854,3 +854,31 @@
def remove_args(self, arg):
self.update_args(arg, remove=True)
+
+
+class LVM(base.Base):
+ """A convenience class for querying LVM volume groups
+ and their associated attributes
+ """
+
+ def vgs(self):
+ return self._query_lvm("vg_name")
+
+ class VG(base.Base):
+ def __init__(self, name):
+ self.name = name
+
+ def tags(self):
+ return LVM._query_lvm("tags", self.name)
+
+ def pv_names(self):
+ return LVM._query_lvm("pv_name", self.name)
+
+ @classmethod
+ def _query_lvm(self, option, pv=None):
+ if pv:
+ return [x.strip() for x in process.check_output(["lvm", "vgs",
+ "--noheadings", "-o", option, pv]).split("\n")]
+ else:
+ return [x.strip() for x in process.check_output(["lvm", "vgs",
+ "--noheadings", "-o", option]).split("\n")]
--
To view, visit http://gerrit.ovirt.org/27606
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I33008a140c7a74afba794c29ba7acbcec89a53ed
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list