from optparse import OptionParser
from sfatables import commands, matches, targets
-from sfatables.xmlextension import Xmlextension
from sfatables.globals import *
from sfatables.commands.List import *
from sfatables.xmlrule import *
return
+ def set_context(self, request_context):
+ return
+
def apply(self, rspec):
intermediate_rspec = rspec
for rule in self.sorted_rule_list:
intermediate_rspec = rule.apply_interpreted(intermediate_rspec)
+ if (rule.terminal):
+ break
- return intermediate_rspec
+ final_rspec = XMLRule().wrap_up(intermediate_rspec)
+ return final_rspec
def main():
incoming = SFATablesRules('INCOMING')
outgoing = SFATablesRules('OUTGOING')
- rspec = """
-<rspec>
- <request-context>
- <sfa><user><hrn>plc.princeton.sapan</hrn></user></sfa>
- </request-context>
-
- <sfatables-rule>
- <argument>
- <name>hrn</name>
- <value>plc</value>
- </argument>
- <argument>
- <name>whitelist</name>
- <value>plc.princeton</value>
- </argument>
- <argument>
- <name>blacklist</name>
- <value>plc.tp</value>
- </argument>
- </sfatables-rule>
- <request>
- <nodespec>
- <node name="plc.princeton.planetlab-01"/>
- <node name="plc.princeton.planetlab-02"/>
- <node name="plc.princeton.planetlab-03"/>
- <node name="plc.princeton.planetlab-04"/>
- <node name="plc.tp.planetlab3"/>
- </nodespec>
- </request>
-</rspec>
- """
+ 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)