(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Thu, 3 Sep 2009 19:09:04 +0000 (19:09 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Thu, 3 Sep 2009 19:09:04 +0000 (19:09 +0000)
sfatables/commands/Add.py
sfatables/matches/hrn.xml
sfatables/targets/RESTRICT_TO_NODES.xml [new file with mode: 0644]
sfatables/targets/RESTRICT_TO_NODES.xml.orig [new file with mode: 0644]
sfatables/targets/RESTRICT_TO_NODE_GROUP.xml [new file with mode: 0644]
sfatables/targets/RESTRICT_TO_NODE_GROUP.xml.orig [new file with mode: 0644]
sfatables/targets/filternodes.xsl [deleted file]
sfatables/targets/restrict_to_nodes.xsl [new file with mode: 0644]

index 5064ee6..26ba543 100644 (file)
@@ -39,6 +39,8 @@ class Add(Command):
 
             if (hasattr(match_options,option_name)):
                 context = p.xpathEval("//rule/argument[name='%s']"%option_name)
+                import pdb
+                pdb.set_trace()
                 if (not context):
                     raise Exception('Unknown option %s for match %s'%(option,option['name']))
                 else:
index e6444e8..a931927 100644 (file)
@@ -8,7 +8,8 @@ as the one matched by this rule.
 -->
 
 <match name="hrn">
-    <context select="//sfa//user/hrn"/>
+    <!-- Empty context. We _always_ get the hrn of the current user -->
+    <context select="//sfa/current/user@hrn"/>
     <rule>
         <argument>
             <name>user-hrn</name>
diff --git a/sfatables/targets/RESTRICT_TO_NODES.xml b/sfatables/targets/RESTRICT_TO_NODES.xml
new file mode 100644 (file)
index 0000000..538db28
--- /dev/null
@@ -0,0 +1,18 @@
+<target name="RESTRICT_TO_NODES">
+    <!-- The context is empty, since this target does not require any input from SFA -->
+    <context select=""/>
+    <rule>
+        <argument>
+            <name>whitelist</name>
+            <help>Prefix of nodes to whitelist for this match.</help>
+            <operand>PREFIX</operand>
+        </argument>
+        <argument>
+            <name>blacklist</name>
+            <help>Prefix of nodes to blacklist for this match.</help>
+            <operand>PREFIX</operand>
+        </argument>
+
+    </rule>
+    <processor filename="restrict_to_nodes.xsl"/>
+</match>
diff --git a/sfatables/targets/RESTRICT_TO_NODES.xml.orig b/sfatables/targets/RESTRICT_TO_NODES.xml.orig
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sfatables/targets/RESTRICT_TO_NODE_GROUP.xml b/sfatables/targets/RESTRICT_TO_NODE_GROUP.xml
new file mode 100644 (file)
index 0000000..bb4465b
--- /dev/null
@@ -0,0 +1,19 @@
+<target name="RESTRICT_TO_NODE_GROUP">
+    <!-- In this case, we need the list of nodes in the [white,black]-listed nodegroups. We specify these with an XPath expression.
+         The expression can have SFA variables, specified using the prefix '%' -->
+    <context select="//sfa/nodes/node[name=%whitelist]/@name" name="whitelist"/>
+    <context select="//sfa/nodes/node[name=%blacklist]/@name" name="blacklist"/>
+    <rule>
+        <argument>
+            <name>whitelist</name>
+            <help>Name of whitelisted node group</help>
+            <operand>NODE-GROUP</operand>
+        </argument>
+        <argument>
+            <name>blacklist</name>
+            <help>Name of the blacklisted node group</help>
+            <operand>NODE-GROUP</operand>
+        </argument>
+    </rule>
+    <processor filename="restrict_to_nodes.xsl"/>
+</match>
diff --git a/sfatables/targets/RESTRICT_TO_NODE_GROUP.xml.orig b/sfatables/targets/RESTRICT_TO_NODE_GROUP.xml.orig
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sfatables/targets/filternodes.xsl b/sfatables/targets/filternodes.xsl
deleted file mode 100644 (file)
index d65a2ae..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- This is an aggregate-specific target for the PL aggregate.
-     Its function is to drop nodes that do not match the user-specified pattern.
--->
-
-<xsl:stylesheet version="1.0"
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-    <xsl:template match="/">
-        <xsl:variable name="result">
-            <xsl:for-each select="//rspec-match/context-input//nodespec">
-                <xsl:variable name="context-hostname" select="hostname"/>
-                <xsl:for-each select="//rspec-match/rule-input//user">
-                    <xsl:choose>
-                    <xsl:when test="starts-with($context-hrn, hrn)">
-                        True
-                    </xsl:when>
-                    <xsl:otherwise>
-                        False
-                    </xsl:otherwise>
-                </xsl:choose>
-                </xsl:for-each>
-            </xsl:for-each>
-        </xsl:variable>
-        <xsl:value-of select="$result"/>
-    </xsl:template>
-</xsl:stylesheet>
diff --git a/sfatables/targets/restrict_to_nodes.xsl b/sfatables/targets/restrict_to_nodes.xsl
new file mode 100644 (file)
index 0000000..bf63cbc
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:template match="/">
+        <xsl:variable name="whitelist_prefix" select="//rule/argument[name='whitelist']/value"/>
+        <xsl:variable name="nodes_minus_whitelist" select="//request/nodespec/node"/>
+        <xsl:value-of select="$nodes_minus_whitelist"/>
+    </xsl:template>
+</xsl:stylesheet>