'sfa/client/genidump.py',
'sfatables/sfatables',
]
-remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in bins ]
package_dirs = [ 'sfa',
'sfa/client',
'sfatables/processors',
]
+
data_files = [('/etc/sfa/', [ 'config/aggregates.xml',
'config/registries.xml',
'config/sfa_config',
'config/sfi_config']),
- ('/etc/sfatables/matches/', glob('sfatables/matches/*')),
- ('/etc/sfatables/targets/', glob('sfatables/targets/*')),
+ ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
+ ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
('/etc/init.d/', ['sfa/init.d/sfa'])]
# add sfatables processors as data_files
if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
python_path = sys.path
- site_packages_path = [ path + os.sep + 'sfa' for path in python_path if path.endswith('site-packages')]
- remove_dirs = ['/etc/sfa/'] + site_packages_path
+ site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
+ site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
+ remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
+ remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in bins ]
remove_files = remove_bins + initscripts
# remove files
print "success"
except: print "failed"
# remove directories
+ print remove_dirs
for directory in remove_dirs:
print "removing", directory, "...",
try:
rm -rf $RPM_BUILD_ROOT
%files
+# sfa and sfatables depend each other.
+/etc/sfatables/*
%{python_sitelib}/*
/usr/bin/keyconvert
/var/www/html/wsdl/*.wsdl
-# sfa and sfatables depend each other.
-/etc/sfatables/*
-%{python_sitelib}/sfatables/*
%files plc
+import os.path
+
sfatables_config = '/etc/sfatables'
-match_dir = 'matches'
-target_dir = 'targets'
+match_dir = os.path.join(sfatables_config, "matches")
+target_dir = os.path.join(sfatables_config, "targets")
+++ /dev/null
-all="""
-hrn
-slice-whitelist
-all
-""".split()
from optparse import OptionParser
from sfatables import commands, matches, targets
-from sfatables.xmlextension import Xmlextension
from sfatables.globals import *
from sfatables.commands.List import *
from sfatables.xmlrule import *
import sys
import os
import pdb
+import glob
import libxml2
from optparse import OptionParser
-from sfatables import commands, matches, targets
+from sfatables import commands
from sfatables.xmlextension import Xmlextension
from sfatables.globals import *
return command_dict
-def load_xml_extensions(module, dir, list):
+def load_xml_extensions(module, ext_dir):
ext_dict={}
- for ext_name in list:
- module = Xmlextension(dir, ext_name)
+ exts = glob.glob(ext_dir + os.path.sep + "*")
+ for ext in exts:
+ module = Xmlextension(ext)
+ # get the filename and get rid of the ".xml" extension
+ ext_name = os.path.extsep.join(os.path.splitext(os.path.basename(ext))[:-1])
ext_dict[ext_name]=module
+ print "Loaded:", ext_name, ext
return ext_dict
if (command.matches):
if (len(pargs)<2):
raise Exception("Must specify match for this command")
- match_dict = load_xml_extensions("sfatables.matches",match_dir, matches.all)
+ match_dict = load_xml_extensions("sfatables.matches",match_dir)
match_parser = create_parser_xml_ext(match_dict)
matches_str = ",".join(match_dict.keys())
match_parser.add_option('-m','--match',dest='name',help='Match name (one of %s)'%matches_str, metavar = 'MATCH')
if (command.targets):
if (len(pargs)<3):
raise Exception("Must specify a target for this command")
- target_dict = load_xml_extensions("sfatables.targets",target_dir,targets.all)
+ target_dict = load_xml_extensions("sfatables.targets",target_dir)
target_parser = create_parser_xml_ext(target_dict)
targets_str = ",".join(target_dict.keys())
- target_parser.add_option('-j','--jump',dest='name',help='Target name (one of %s)'%targets, metavar = 'TARGET')
+ target_parser.add_option('-j','--jump',dest='name',help='Target name (one of %s)'%targets_str, metavar = 'TARGET')
target_parser.add_option('-e','--element',dest='element',help='Element name', metavar = 'ELEMENT')
(target_options, args) = target_parser.parse_args(pargs[2])
try:
</argument>
</rule>
<processor filename="restrict_to_nodes.xsl"/>
-</match>
+</target>
+++ /dev/null
-all="""
-RESTRICT_SLICE_DOMAIN
-ACCEPT
-REJECT
-RESTRICT_SLICE_PROP
-""".split()
from sfatables.globals import *
class Xmlextension:
- def __init__(self, dir, component_name):
+ def __init__(self, file_path):
self.context = ""
self.processor = ""
self.operand = "VALUE"
self.arguments = []
self.terminal = 0
- filename = dir+"/"+component_name+".xml"
- self.xmldoc = libxml2.parseFile(filename)
+ self.xmldoc = libxml2.parseFile(file_path)
# TODO: Check xmldoc against a schema
p = self.xmldoc.xpathNewContext()