2 from sfatables.globals import *
10 arguments = {'match':None,'target':None}
11 processors = {'match':None,'target':None}
12 context = {'match':None,'target':None}
14 def load_xml_extension (self, type, chain, rule_number):
15 filename = sfatables_config+"/"+chain+"/"+"sfatables-%d-%s"%(rule_number,type)
17 self.xmldoc = libxml2.parseFile(filename)
18 p = self.xmldoc.xpathNewContext()
20 context = p.xpathEval('//context/@select')
21 self.context[type] = context[0].content
23 processor = p.xpathEval('//processor/@filename')
25 context = p.xpathEval('//attributes/attribute[@terminal="yes"]')
29 self.processors[type] = processor[0].content
30 self.arguments[type] = p.xpathEval('//rule')
35 def wrap_rspec (self, type, rspec):
36 argument = self.arguments[type]
37 p = rspec.xmldoc.xpathNewContext()
38 root_node = p.xpathEval('/RSpec')
39 if (not root_node or not root_node):
40 raise Exception('An evil aggregate manager sent me a malformed RSpec. Please see the stack trace to identify it.')
42 root_node.addChild(arguments[type])
45 def __init__(self, chain, rule_number):
47 self.load_xml_extension('match', chain, rule_number)
48 self.load_xml_extension('target',chain, rule_number)
49 self.rule_number = rule_number