From 9fcd24492ce3094030aa0f2fc73c86b2259cce4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Fri, 2 Oct 2009 10:26:36 +0000 Subject: [PATCH] install sfatables --- setup.py | 41 +++++++++++++++++++++++++++-------------- sfa.spec | 15 +++++++++++++++ sfatables/xmlrule.py | 2 +- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 97309e3b..6b554e4e 100755 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ Installation script for the geniwrapper module """ import sys, os, os.path +from glob import glob import shutil from distutils.core import setup @@ -17,6 +18,7 @@ bins = [ 'config/sfa-config-tty', 'sfa/client/getRecord.py', 'sfa/client/setRecord.py', 'sfa/client/genidump.py', + 'sfatables/sfatables', ] remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in bins ] @@ -29,23 +31,37 @@ package_dirs = [ 'sfa', 'sfa/util', 'sfa/rspecs', 'sfa/rspecs/aggregates', - 'sfa/rspecs/aggregates/vini' + 'sfa/rspecs/aggregates/vini', + 'sfatables', + 'sfatables/commands', + 'sfatables/processors', ] -data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml', - 'config/registries.xml', - 'config/sfa_config', - 'config/sfi_config', - ]), - ('/etc/init.d/', ['sfa/init.d/sfa']), - ] + +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/init.d/', ['sfa/init.d/sfa'])] + +# add sfatables processors as data_files +processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)] +data_files.append(('/etc/sfatables/processors/', processor_files)) +processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)] +for d in processor_subdirs: + etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d)) + d_files = [f for f in glob(d + '/*') if os.path.isfile(f)] + data_files.append((etc_dir, processor_files)) + initscripts = [ '/etc/init.d/sfa' ] - + 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 remove_files = remove_bins + initscripts - + # remove files for filepath in remove_files: print "removing", filepath, "...", @@ -60,15 +76,12 @@ if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']: shutil.rmtree(directory) print "success" except: print "failed" - else: - # avoid repeating what's in the specfile already setup(name='sfa', packages = package_dirs, data_files = data_files, ext_modules = [], py_modules = [], - scripts = bins, - ) + scripts = bins) diff --git a/sfa.spec b/sfa.spec index 6d028549..99474459 100644 --- a/sfa.spec +++ b/sfa.spec @@ -50,6 +50,11 @@ Summary: the SFA experimenter-side CLI Group: Applications/System Requires: sfa +%package sfatables +Summary: sfatables policy tool for SFA +Group: Applications/System +Requires: sfa + %description This package provides the python libraries that the SFA implementation requires @@ -61,6 +66,11 @@ between the existing PlanetLab interfaces and the SFA API. This package provides the client side of the SFA API, in particular sfi.py, together with other utilities. +%description sfatables +sfatables is a tool for defining access and admission control policies +in an SFA network, in much the same way as iptables is for ip +networks. + %prep %setup -q @@ -98,6 +108,11 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/setRecord.py* %{_bindir}/genidump.py* +%files sfatables +/etc/sfatables/* +%{_bindir}/sfatables +%{python_sitelib}/sfatables/* + %pre plc [ -f %{_sysconfdir}/init.d/sfa ] && service sfa stop ||: diff --git a/sfatables/xmlrule.py b/sfatables/xmlrule.py index fb0ef79d..c363ab92 100644 --- a/sfatables/xmlrule.py +++ b/sfatables/xmlrule.py @@ -17,7 +17,7 @@ class XMLRule: processor = self.processors[type] # XXX TO CLEAN UP - filepath = 'processors/' + processor + filepath = os.path.join(sfatables_config, 'processors', processor) # XXX styledoc = libxml2.parseFile(filepath) -- 2.43.0