X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fruntime.py;h=99226f4fbedda2803af5c5052a4bd715f39212c5;hb=bfcea75fd4f7d91b186f4f0e479db0e6f0a231ae;hp=ef3ccc42dc8c8773fdc84d5159213eeab73de6d9;hpb=740ac677f9029cbd5697ff7e29330d0c30fd63d4;p=sfa.git diff --git a/sfatables/runtime.py b/sfatables/runtime.py index ef3ccc42..99226f4f 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -3,9 +3,10 @@ import sys import os import pdb +from optparse import OptionParser + import libxml2 -from optparse import OptionParser from sfatables import commands from sfatables.globals import * from sfatables.commands.List import * @@ -50,7 +51,9 @@ class SFATablesRules: childNode = self.create_xml_node(k, context_dict[k]) node.addChild(childNode) else: - node.addContent(context_dict[k]) + childNode = libxml2.newNode(k) + childNode.addContent(context_dict[k]) + node.addChild(childNode) return node def add_request_context_to_rspec(self, doc): @@ -84,16 +87,20 @@ class SFATablesRules: return final_rspec + def print_rules(self): + for rule in self.sorted_rule_list: + print rule.processors + def main(): incoming = SFATablesRules('INCOMING') incoming.set_context({'sfa':{'user':{'hrn':'plc.princeton.sapanb'}}}) outgoing = SFATablesRules('OUTGOING') print "%d rules loaded for INCOMING chain"%len(incoming.sorted_rule_list) - print incoming.sorted_rule_list[0].processors + incoming.print_rules() print "%d rules loaded for OUTGOING chain"%len(outgoing.sorted_rule_list) - print outgoing.sorted_rule_list[0].processors + outgoing.print_rules() rspec = open(sys.argv[1]).read() newrspec = incoming.apply(rspec)