Blame SOURCES/0010-vmcore-properly-configure-Augeas.patch

06486d
From 4c754657a3581b996ae540fbcbc261efd1f65ca2 Mon Sep 17 00:00:00 2001
06486d
From: Jakub Filak <jfilak@redhat.com>
06486d
Date: Thu, 16 Jan 2014 12:20:40 +0100
06486d
Subject: [ABRT PATCH 10/12] vmcore: properly configure Augeas
06486d
06486d
Configure Augeas to parse only required configuration files:
06486d
- /etc/mtab
06486d
- /ect/kdump.conf
06486d
06486d
Related to rhbz#1054158
06486d
06486d
Signed-off-by: Jakub Filak <jfilak@redhat.com>
06486d
---
06486d
 src/hooks/abrt_harvest_vmcore.py.in | 16 ++++++++++++++--
06486d
 1 file changed, 14 insertions(+), 2 deletions(-)
06486d
06486d
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
06486d
index 64d6777..ecfb32d 100644
06486d
--- a/src/hooks/abrt_harvest_vmcore.py.in
06486d
+++ b/src/hooks/abrt_harvest_vmcore.py.in
06486d
@@ -17,6 +17,18 @@ import augeas
06486d
 import problem
06486d
 
06486d
 
06486d
+def get_augeas(module, file_path):
06486d
+    """
06486d
+    A function for efficient configuration of Augeas.
06486d
+    Augeas modules are placed in /usr/share/augeas/lenses/dist
06486d
+    """
06486d
+
06486d
+    aug_obj = augeas.Augeas(flags=augeas.Augeas.NO_MODL_AUTOLOAD)
06486d
+    aug_obj.set("/augeas/load/{0}/lens".format(module), "{0}.lns".format(module))
06486d
+    aug_obj.set("/augeas/load/{0}/incl".format(module), file_path)
06486d
+    aug_obj.load()
06486d
+    return aug_obj
06486d
+
06486d
 def get_mount_point(part_id):
06486d
     """
06486d
     A function used to look up a mount point in mtab using
06486d
@@ -26,7 +38,7 @@ def get_mount_point(part_id):
06486d
     """
06486d
 
06486d
     # look up the identifier in /etc/mtab
06486d
-    result = augeas.Augeas().get("/files/etc/mtab/*"
06486d
+    result = get_augeas("Fstab", "/etc/mtab").get("/files/etc/mtab/*"
06486d
                                  "[spec=\"" + part_id + "\"]/file")
06486d
     if result:
06486d
         return result
06486d
@@ -53,7 +65,7 @@ def parse_kdump():
06486d
                          "default path '%s'\n" % dump_path)
06486d
         return dump_path
06486d
 
06486d
-    aug_obj = augeas.Augeas()
06486d
+    aug_obj = get_augeas("Kdump", "/etc/kdump.conf")
06486d
     # check for path variable in kdump.conf
06486d
     kdump_path = aug_obj.get("/files/etc/kdump.conf/path")
06486d
     if kdump_path:
06486d
-- 
06486d
1.8.3.1
06486d