3 # Delete all the database records for SFA. This tool is used to clean out SFA
4 # records during testing.
6 # Authority info (maintained by the hierarchy module in a subdirectory tree)
7 # is not purged by this tool and may be deleted by a command like 'rm'.
12 from optparse import OptionParser
14 from sfa.trust.hierarchy import *
15 from sfa.util.record import *
16 from sfa.util.table import SfaTable
17 from sfa.util.sfalogging import logger
20 usage="%prog: trash the registry DB (the 'sfa' table in the 'planetlab5' database)"
21 parser = OptionParser(usage=usage)
22 parser.add_option('-f','--file-system',dest='clean_fs',action='store_true',default=False,
23 help='Clean up the /var/lib/sfa/authorities area as well')
24 (options,args)=parser.parse_args()
28 logger.info("Purging SFA records from database")
30 table.sfa_records_purge()
32 # just remove all files that do not match 'server.key' or 'server.cert'
33 preserved_files = [ 'server.key', 'server.cert']
34 for (dir,_,files) in os.walk('/var/lib/sfa/authorities'):
36 if file in preserved_files: continue
39 if not os.path.exists(path):
40 logger.info("Unlinked file %s"%path)
42 logger.error("Could not unlink file %s"%path)
43 if __name__ == "__main__":