X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fcommands%2FDelete.py;h=50b1d6261bd85e26b2708246aa7945d66f0726d4;hb=c451060afdf4ef60cdfea767ba6f00d6ffce66f8;hp=063caab92801cf1bbe7ead3d7c2a01ca36abba9e;hpb=7890210eadbb59fa7cebdadf698ff2b20ba11d0a;p=sfa.git diff --git a/sfatables/commands/Delete.py b/sfatables/commands/Delete.py index 063caab9..50b1d626 100644 --- a/sfatables/commands/Delete.py +++ b/sfatables/commands/Delete.py @@ -1,18 +1,32 @@ import os, time +from sfatables.globals import * +from sfatables.command import Command -class Command: - options = [] - help = '' - key='' +class Delete(Command): + options = [('-D','--delete')] + help = 'Delete a rule from a chain' + key='delete_rule' matches = False targets = False 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." + return + + 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)