(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 1 Sep 2009 15:17:39 +0000 (15:17 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 1 Sep 2009 15:17:39 +0000 (15:17 +0000)
sfatables/command.py
sfatables/commands/Add.py
sfatables/sfatables

index 5a33928..825c9f2 100644 (file)
@@ -15,5 +15,5 @@ class Command:
         # Override this function
         return True
 
-    def __call__(self, coption, moptions, toptions):
+    def __call__(self, coptions, moptions, toptions):
         return self.call(coptions,moptions,toptions)
index d8bd9a7..ef2b26e 100644 (file)
@@ -1,6 +1,8 @@
 import os, time
 from sfatables.command import Command
 
+import sfatables.globals
+
 class Add(Command):
     options = [('-A','--add')]
     help = 'Add a rule to a chain'
@@ -11,6 +13,15 @@ class Add(Command):
         return
 
     def call(self, command_options, match_options, target_options):
-        # Override this function
+        filename = match_dir + "/"+match_options.name+".xml"
+        xmldoc = libxml2.parseFile(filename)
+    
+        p = self.xmldoc.xpathNewContext()
+
+        context = p.xpathEval("//rule/argument[name='user-hrn']")
+        pdb.set_trace()
+
+
+
         return True
 
index 1428dc0..59628e7 100755 (executable)
@@ -52,9 +52,8 @@ def create_parser_xml_ext(ext_dict):
     
     for k in ext_dict.keys():
         command = ext_dict[k]
-        pdb.set_trace()
         for arg in command.arguments:
-            parser.add_option(None,"--"+arg,dest=arg,help=command.help,metavar=command.operand)
+            parser.add_option('',"--"+arg['name'],dest=arg['name'],help=arg['help'],metavar=arg['target'])
 
     return parser
 
@@ -100,9 +99,9 @@ def main():
             raise Exception("Must specify a target for this command")
         target_dict = load_xml_extensions("sfatables.targets",targets.all)
         target_parser = create_parser_xml_ext(target_dict)
-        targets = ",".join(target_dict.keys())
-        (target_options, args) = target_parser.parse_args(pargs[2])
+        targets_str = ",".join(target_dict.keys())
         target_parser.add_option('-j','--jump',dest='target_name',help='Target name (one of %s)'%targets, metavar = 'TARGET')
+        (target_options, args) = target_parser.parse_args(pargs[2])
     else:
         target_options = None