Modified a processor to conform to the XML schema of match parameters.
Sapan Bhatia [Tue, 27 Oct 2009 03:05:08 +0000 (03:05 +0000)]
sfatables/processors/hrn.xsl
sfatables/runtime.py
sfatables/test.rspec [new file with mode: 0644]
sfatables/test.sfarspec
sfatables/xmlrule.py

index 426c5fd..47a8b62 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-    <xsl:variable name="context-hrn" select="//request-context//hrn"/>
+    <xsl:variable name="context-hrn" select="//request-context/sfa/user/hrn"/>
 
     <!-- Magic sauce -->
 
@@ -9,9 +9,10 @@
             <xsl:apply-templates select="@* | node()"/>
     </xsl:template>
 
-    <xsl:template match="//request-context//user">
+    <xsl:template match="//match-context/argument[name='user-hrn']">
+                    <xsl:value-of select="hrn"/>
                     <xsl:choose>
-                    <xsl:when test="starts-with($context-hrn, hrn)">
+                    <xsl:when test="starts-with($context-hrn, value)">
                         <result verdict="True"/> <!--Match -->
                     </xsl:when>
                     <xsl:otherwise>
index ef3ccc4..69dd665 100644 (file)
@@ -86,7 +86,7 @@ class SFATablesRules:
 
 def main():
     incoming = SFATablesRules('INCOMING')
-    incoming.set_context({'sfa':{'user':{'hrn':'plc.princeton.sapanb'}}})
+    incoming.set_context({'sfa':{'user':{'hrn':'ple.princeton.sapanb'}}})
 
     outgoing = SFATablesRules('OUTGOING')
     print "%d rules loaded for INCOMING chain"%len(incoming.sorted_rule_list)
diff --git a/sfatables/test.rspec b/sfatables/test.rspec
new file mode 100644 (file)
index 0000000..a7173e8
--- /dev/null
@@ -0,0 +1,13 @@
+<!-- run "runtime.py sfarspec" to apply current rule set to this file -->
+
+<RSpec>
+     <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>
index a7173e8..b84bec4 100644 (file)
@@ -1,6 +1,8 @@
 <!-- run "runtime.py sfarspec" to apply current rule set to this file -->
 
 <RSpec>
+     <request-context><sfa><user><hrn>plc.princeton.sapanb</hrn></user></sfa></request-context>
+     <match-context><argument><name>user-hrn</name><value>plc.princeton.sapanb</value></argument></match-context>
      <request>
         <nodespec>
             <node name="plc.princeton.planetlab-01"/>
index 9e06bbf..ea73a4f 100644 (file)
@@ -85,8 +85,10 @@ class XMLRule:
         #       else rspec
         
         if (self.match(rspec)):
+            print "Matched!"
             return (True,self.wrap_up(self.target(rspec)))
         else:
+            print "Not Matched!"
             return (False,self.wrap_up(rspec))