import os, time
+from sfatables.globals import *
from sfatables.command import Command
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)
def __init__(self):
return
-
def get_info(self, type, xmlextension_path):
xmldoc = libxml2.parseFile(xmlextension_path)
p = xmldoc.xpathNewContext()
import libxml2
+import libxslt
from sfatables.globals import *
class XMLRule:
filepath = 'processors/' + processor
# XXX
- styledoc = libxml2.parseFile(processor)
+ styledoc = libxml2.parseFile(filepath)
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc(rspec)
result = style.applyStylesheet(doc, None)
- processed_result = style.saveResultToString(result, 0)
+ stylesheet_result = style.saveResultToString(result)
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()