[PATCH] Drop iptables-save comments and chain counters from iptables inventory.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 func/minion/modules/iptables/__init__.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/func/minion/modules/iptables/__init__.py b/func/minion/modules/iptables/__init__.py
index db11a23..ccc7645 100644
--- a/func/minion/modules/iptables/__init__.py
+++ b/func/minion/modules/iptables/__init__.py
@@ -12,6 +12,7 @@
 # our modules
 from func.minion.modules import func_module
 from func.minion.modules.iptables.common import *
+import re
 
 IPTABLES_SAVE_FILE = "/etc/sysconfig/iptables"
 
@@ -111,7 +112,19 @@ class Iptables(func_module.FuncModule):
         return call_if_policy("INPUT", "DROP", "-I OUTPUT -d %s -j ACCEPT" % ip)
 
     def inventory(self):
-        return self.dump()
+        raw = self.dump()
+        output = ""
+        for line in raw.splitlines():
+            # Drop commentlines:
+            if re.search("^#", line):
+                continue
+            # Null chain counters:
+            if re.search("^:.*$", line):
+                nulled = re.sub('(^:.*)\[\d*:\d*\](.*$)', r'\1[0:0]\2', line)
+                output = output + nulled + "\n"
+                continue
+            output = output + line + "\n"
+        return output
 
     def dump(self, counters=False):
         """
-- 
1.7.1

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux