From: Sapan Bhatia Date: Tue, 1 Sep 2009 15:17:39 +0000 (+0000) Subject: (no commit message) X-Git-Tag: sfa-0.9-1~38 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=dc1c09e790d507ba6f2258459374a4dcda7decce;p=sfa.git --- diff --git a/sfatables/command.py b/sfatables/command.py index 5a339289..825c9f2b 100644 --- a/sfatables/command.py +++ b/sfatables/command.py @@ -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) diff --git a/sfatables/commands/Add.py b/sfatables/commands/Add.py index d8bd9a76..ef2b26e2 100644 --- a/sfatables/commands/Add.py +++ b/sfatables/commands/Add.py @@ -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 diff --git a/sfatables/sfatables b/sfatables/sfatables index 1428dc06..59628e75 100755 --- a/sfatables/sfatables +++ b/sfatables/sfatables @@ -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