Added element support to the main sfatables file
authorSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 22 Sep 2009 19:44:34 +0000 (19:44 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 22 Sep 2009 19:44:34 +0000 (19:44 +0000)
sfatables/commands/Add.py
sfatables/matches/hrn.xml
sfatables/sfatables
sfatables/targets/RESTRICT_SLICE_DOMAIN.xml

index e0c190f..f5193eb 100644 (file)
@@ -33,15 +33,19 @@ class Add(Command):
         p = xmldoc.xpathNewContext()
 
         supplied_arguments = options.arguments
-        element = options.element
+        if (hasattr(options,'element') and options.element):
+            element = options.element
+        else:
+            element='*'
+
         for option in supplied_arguments:
             option_name = option['name']
             option_value = getattr(options,option_name)
 
             if (hasattr(options,option_name)):
-                context = p.xpathEval("//rule[@element='%s' or @element='*']/argument[name='%s']"%element, option_name)
+                context = p.xpathEval("//rule[@element='%s' or @element='*']/argument[name='%s']"%(element, option_name))
                 if (not context):
-                    raise Exception('Unknown option %s for match %s'%(option,option['name']))
+                    raise Exception('Unknown option %s for match %s and element %s'%(option,option['name'], element))
                 else:
                     # Add the value of option
                     valueNode = libxml2.newNode('value')
index 6da2e70..14bc26e 100644 (file)
@@ -7,13 +7,13 @@ For this simple match, we just need to look at sfa-input.
 
 <match name="hrn">
     <!-- Empty context. We _always_ get the hrn of the current user -->
+    <rule element='*'>
     <context select="//sfa/current/user@hrn"/>
-    <rule>
         <argument>
             <name>user-hrn</name>
             <help>HRN of the user requesting resouces</help>
             <operand>HRN</operand>
         </argument>
-    </rule>
     <processor filename="hrn.xsl"/>
+    </rule>
 </match>
index 32b2f8d..2f20f3f 100755 (executable)
@@ -113,7 +113,7 @@ def main():
         target_parser = create_parser_xml_ext(target_dict)
         targets_str = ",".join(target_dict.keys())
         target_parser.add_option('-j','--jump',dest='name',help='Target name (one of %s)'%targets, metavar = 'TARGET')
-        target_parser.add_option('-e','--element',dest='element',help='Element name'%targets, metavar = 'ELEMENT')
+        target_parser.add_option('-e','--element',dest='element',help='Element name', metavar = 'ELEMENT')
         (target_options, args) = target_parser.parse_args(pargs[2])
         try:
             name = target_options.name
index 45f2a4b..2fbffd9 100644 (file)
@@ -1,7 +1,7 @@
 <target name="RESTRICT_SLICE_DOMAIN">
     <rule element="node">
-    <!-- The context is empty, since this target does not require any input from SFA -->
-    <context select=""/>
+        <!-- The context is empty, since this target does not require any input from SFA -->
+        <context select=""/>
         <argument>
             <name>whitelist</name>
             <help>Prefix of nodes to whitelist for this match.</help>
@@ -12,6 +12,6 @@
             <help>Prefix of nodes to blacklist for this match.</help>
             <operand>PREFIX</operand>
         </argument>
-    <processor filename="restrict_to_nodes.xsl"/>
+        <processor filename="restrict_to_nodes.xsl"/>
     </rule>
 </target>