X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fruntime.py;h=a5363352d6a191e307304754de213012a9f2c2a1;hb=cf4cfc2fd8cc0260d5cdce30c6fe0d42d0e40cd1;hp=b76ec0a8dda631b20081a977dd01e70cbfcb98e8;hpb=73b163a7ea35209e0675a7c7cef367946928a96f;p=sfa.git diff --git a/sfatables/runtime.py b/sfatables/runtime.py index b76ec0a8..a5363352 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -50,7 +50,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): @@ -74,8 +76,8 @@ class SFATablesRules: intermediate_rspec = doc for rule in self.sorted_rule_list: - intermediate_rspec = rule.apply_interpreted(intermediate_rspec) - if (rule.terminal): + (matched,intermediate_rspec) = rule.apply_interpreted(intermediate_rspec) + if (rule.terminal and matched): break final_rspec = self.wrap_up(intermediate_rspec) @@ -84,16 +86,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)