(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Wed, 12 Aug 2009 18:07:59 +0000 (18:07 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Wed, 12 Aug 2009 18:07:59 +0000 (18:07 +0000)
sfatables/__init__.py [new file with mode: 0644]
sfatables/commands/Add.py
sfatables/commands/Delete.py
sfatables/commands/List.py
sfatables/commands/SetDefault.py
sfatables/sfatables.py

diff --git a/sfatables/__init__.py b/sfatables/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 063caab..79bb2d9 100644 (file)
@@ -1,9 +1,10 @@
 import os, time
+from sfa.sfatables.command import Add
 
-class Command:
-    options = []
-    help = ''
-    key=''
+class Add(Command):
+    options = [('-A','--add')]
+    help = 'Add a rule to a chain'
+    key='add_rule'
     matches = False
     targets = False
 
index 063caab..e59da62 100644 (file)
@@ -1,9 +1,10 @@
 import os, time
+from sfa.sfatables.command import Add
 
-class Command:
-    options = []
-    help = ''
-    key=''
+class Add(Command):
+    options = [('-D','--delete')]
+    help = 'Delete a rule from a chain'
+    key='delete_rule'
     matches = False
     targets = False
 
index 063caab..38f5ebc 100644 (file)
@@ -1,9 +1,10 @@
 import os, time
+from sfa.sfatables.command import Add
 
-class Command:
-    options = []
-    help = ''
-    key=''
+class List(Command):
+    options = [('-L','--list')]
+    help = 'List a chain'
+    key='list_rule'
     matches = False
     targets = False
 
index 063caab..8fac405 100644 (file)
@@ -1,9 +1,10 @@
 import os, time
+from sfa.sfatables.command import Add
 
-class Command:
-    options = []
-    help = ''
-    key=''
+class SetDefault(Command):
+    options = [('-P','--default')]
+    help = 'Set the default rule for a chain'
+    key='add_rule'
     matches = False
     targets = False
 
index dbfa712..d9dbcb5 100755 (executable)
@@ -14,7 +14,9 @@ from optparse import OptionParser
 
 def load_extensions(module):
     command_dict={}
-    commands = __import__(module,fromlist=[".".join(module.split('.')[:-1])])
+    module_path = ".".join(module.split('.')[:-1])
+    pdb.set_trace()
+    commands = __import__(module,fromlist=[module_path])
 
     for command_name in commands.all:
         command_module = getattr(commands, command_name)
@@ -40,9 +42,10 @@ def main():
     command_parser = create_parser(command_dict)
     (options, args) = command_parser.parse_args()
 
-    if (len(options.keys() != 1):
+    if (len(options.keys()) != 1):
         raise Exception("sfatables takes one command at a time.\n")
 
+    pdb.set_trace()
     selected_command = command_dict[options.keys()[0]]
 
     match_options = None
@@ -51,12 +54,12 @@ def main():
     if (selected_command.matches):
         match_dict = load_extensions("sfa.sfatables.matches")
         match_parser = create_parser(match_dict)
-        (options, args) = match_parser.parse_args(args[2:]) # Change to next location of --
+        (options, args) = match_parser.parse_args(args[2:]) 
 
     if (selected_command.targets):
         match_dict = load_extensions("sfa.sfatables.targets")
         target_parser = create_parser(match_dict)
-        (options, args) = target_parser.parse_args(args[5:]) # Change to next location of --
+        (options, args) = target_parser.parse_args(args[5:]) 
 
     command(options, match_options, target_options)