[Kimchi-devel] [kimchi-devel][PATCH 2/6] Add helper function to retrieve vg information
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Sun Apr 12 14:13:52 UTC 2015
From: Royce Lv <lvroyce at linux.vnet.ibm.com>
Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 2 ++
src/kimchi/utils.py | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index e4e1a89..63f57d4 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -49,6 +49,8 @@ messages = {
"KCHDISKS0001E": _("Error while getting block devices. Details: %(err)s"),
"KCHDISKS0002E": _("Error while getting block device information for %(device)s."),
+ "KCHLVM0001E": _("Error while getting lvm information %(err)s."),
+
"KCHDL0001E": _("Unable to find distro file: %(filename)s"),
"KCHDL0002E": _("Unable to parse distro file: %(filename)s. Make sure, it is a JSON file."),
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index d71338a..0b11fcb 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -245,6 +245,24 @@ def parse_cmd_output(output, output_items):
return res
+def find_vgs():
+ cmd = ["vgs", "--noheadings", "-o", "vg_name, vg_size"]
+ try:
+ out, error, ret = run_command(cmd, 5)
+ except TimeoutExpired:
+ kimchi_log.warning("volume group query timeout")
+ return list()
+
+ if error:
+ raise OperationFailed("KCHLVM0001E", {'err': error})
+
+ vgs = parse_cmd_output(out, ['name', 'size'])
+ for vg in vgs:
+ vg['path'] = os.path.join('/dev/', vg['name'])
+ vg['pool'] = ''
+ return vgs
+
+
def patch_find_nfs_target(nfs_server):
cmd = ["showmount", "--no-headers", "--exports", nfs_server]
try:
--
2.1.0
More information about the Kimchi-devel
mailing list