X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fcommands%2FDelete.py;h=d90c583f3c6e3069e3bf454191981e207011726e;hb=4f5aa107ea1efb7a1e67da360ab91e7aacbd80a8;hp=cac5445444f8f1aaf594231f2396358c2c23b724;hpb=3911c6d97e010f6cf8faed8fc9800a90028d7aea;p=sfa.git diff --git a/sfatables/commands/Delete.py b/sfatables/commands/Delete.py index cac54454..d90c583f 100644 --- a/sfatables/commands/Delete.py +++ b/sfatables/commands/Delete.py @@ -1,4 +1,5 @@ import os, time +from sfatables.globals import * from sfatables.command import Command class Delete(Command): @@ -11,9 +12,20 @@ class Delete(Command): def __init__(self): return - def call(self): - # Override this function - return True + def call(self, command_options, match_options, target_options): + + if (len(command_options.args)<2): + print "Please specify the chain and the rule number to delete, e.g. sfatables -D INCOMING 1" + + chain = command_options.args[0] + + + rule_number = command_options.args[1] + chain_dir = sfatables_config + "/" + chain + + match_path = chain_dir + "/" + "sfatables-%s-match"%rule_number + target_path = chain_dir + "/" + "sfatables-%s-target"%rule_number + + os.unlink(match_path) + os.unlink(target_path) - def __call__(self, option, opt_str, value, parser, *args, **kwargs): - return self.call(option)