From c6f2a8917e5c158fd7c8b73f52ff31ca99d6f395 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 10 Sep 2009 19:16:40 +0000 Subject: [PATCH] ...contd --- sfatables/exec.py | 14 +++++++++++++- sfatables/xmlrule.py | 5 ++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sfatables/exec.py b/sfatables/exec.py index fcff3aa1..979245d3 100644 --- a/sfatables/exec.py +++ b/sfatables/exec.py @@ -13,7 +13,7 @@ from sfatables.commands.List import * from sfatables.xmlrule import * class SFATablesRules: - sorted_rule_list = None + sorted_rule_list = [] def __init__(self, chain_name): chain_dir_path = "%s/%s"%(sfatables_config,chain_name) @@ -28,3 +28,15 @@ class SFATablesRules: intermediate_rspec = rule.apply(intermediate_rspec) return intermediate_rspec + +def main(): + incoming = SFATablesRules('INCOMING') + outgoing = SFATablesRules('OUTGOING') + + print "%d rules loaded for INCOMING chain\n"%len(incoming.sorted_rule_list) + print "%d rules loaded for OUTGOING chain\n"%len(outgoing.sorted_rule_list) + + return + +if __name__=="__main__": + main() diff --git a/sfatables/xmlrule.py b/sfatables/xmlrule.py index bce804a0..8f36c74d 100644 --- a/sfatables/xmlrule.py +++ b/sfatables/xmlrule.py @@ -1,7 +1,7 @@ import libxml2 from sfatables.globals import * -class Xmlrule: +class XMLRule: rule_number = None chain = None xmldoc = None @@ -26,13 +26,12 @@ class Xmlrule: p.xpathFreeContext() - return def wrap_rspec (self, type, rspec): argument = self.arguments[type] p = rspec.xmldoc.xpathNewContext() root_node = p.xpathEval('/RSpec') - if (!root_node or !len(root_node)): + if (not root_node or not root_node): raise Exception('An evil aggregate manager sent me a malformed RSpec. Please see the stack trace to identify it.') root_node.addChild(arguments[type]) -- 2.43.0