Updating new target names in the initializer.
Sapan Bhatia [Tue, 22 Sep 2009 18:00:05 +0000 (18:00 +0000)]
sfatables/commands/Add.py
sfatables/sfatables
sfatables/targets/__init__.py

index 4f0e606..e0c190f 100644 (file)
@@ -33,12 +33,13 @@ class Add(Command):
         p = xmldoc.xpathNewContext()
 
         supplied_arguments = options.arguments
+        element = options.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/argument[name='%s']"%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']))
                 else:
index 7f61a3f..32b2f8d 100755 (executable)
@@ -113,11 +113,12 @@ 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_options, args) = target_parser.parse_args(pargs[2])
         try:
             name = target_options.name
         except Exception:
-            print "Must specify target name with -m"
+            print "Must specify target name with -j"
 
         if (target_dict.has_key(name)):
             setattr(target_options, 'arguments', target_dict[name].arguments)
index 3a5e632..1dcc2d1 100644 (file)
@@ -1,6 +1,6 @@
 all="""
-RESTRICT_TO_NODES
+RESTRICT_SLICE_DOMAIN
 ACCEPT
 REJECT
-MAX_LINK_BW
+RESTRICT_SLICE_PROP
 """.split()