X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fruntime.py;h=a5363352d6a191e307304754de213012a9f2c2a1;hb=3d7237fa0b5f2b4a60cb97c7fb3b6aecfd94558a;hp=0ed38e0628d5abf4697deb0a93d7202cb397f8b6;hpb=9a053166cdb0187d0514403e92e8719d9a3aa8ee;p=sfa.git diff --git a/sfatables/runtime.py b/sfatables/runtime.py index 0ed38e06..a5363352 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -50,12 +50,14 @@ 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): p = doc.xpathNewContext() - context = p.xpathEval("//Rspec") + context = p.xpathEval("//RSpec") if (not context): raise Exception('Request is not an rspec') else: @@ -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)