X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fruntime.py;h=b155809bfca3b7a55c688df9de889065d6be5f0c;hb=50d80230b924e20e028ed3c0f13ddd6f98cfbe54;hp=0a73482afada6920c53d75fcae7b679c0c3ee69e;hpb=e57b7150dee76d42fc15f9477a3045e5171c8878;p=sfa.git diff --git a/sfatables/runtime.py b/sfatables/runtime.py index 0a73482a..b155809b 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -6,15 +6,16 @@ import pdb import libxml2 from optparse import OptionParser -from sfatables import commands, matches, targets +from sfatables import commands from sfatables.globals import * from sfatables.commands.List import * from sfatables.xmlrule import * class SFATablesRules: def __init__(self, chain_name): + self.contexts = None # placeholder for rspec_manger self.sorted_rule_list = [] - chain_dir_path = "%s/%s"%(sfatables_config,chain_name) + chain_dir_path = os.path.join(sfatables_config,chain_name) rule_list = List().get_rule_list(chain_dir_path) for rule_number in rule_list: self.sorted_rule_list.append(XMLRule(chain_name, rule_number)) @@ -25,7 +26,8 @@ class SFATablesRules: return def apply(self, rspec): - intermediate_rspec = rspec + doc = libxml2.parseDoc(rspec) + intermediate_rspec = doc for rule in self.sorted_rule_list: intermediate_rspec = rule.apply_interpreted(intermediate_rspec) if (rule.terminal): @@ -38,11 +40,10 @@ def main(): incoming = SFATablesRules('INCOMING') outgoing = SFATablesRules('OUTGOING') - rspec = open(sys.argv[1]).read() - - 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) + print "%d rules loaded for INCOMING chain"%len(incoming.sorted_rule_list) + print "%d rules loaded for OUTGOING chain"%len(outgoing.sorted_rule_list) + rspec = open(sys.argv[1]).read() newrspec = incoming.apply(rspec) print newrspec return