removing
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 12 Mar 2012 16:40:41 +0000 (12:40 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 12 Mar 2012 16:40:41 +0000 (12:40 -0400)
sfa/importer/sfa-import.py [deleted file]
sfa/importer/sfaimporter.py [deleted file]

diff --git a/sfa/importer/sfa-import.py b/sfa/importer/sfa-import.py
deleted file mode 100755 (executable)
index 2788282..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-
-import sys
-
-from optparse import OptionParser
-
-from sfa.generic import Generic
-
-from sfa.util.config import Config
-from sfa.util.sfalogging import _SfaLogger
-
-from sfa.trust.hierarchy import Hierarchy
-
-from sfa.importer.sfaimporter import SfaImporter
-
-COMMAND=sys.argv[0]
-
-def main ():
-
-    config = Config()
-    logger = _SfaLogger(logfile='/var/log/sfa_import.log', loggername='importlog')
-    logger.setLevelFromOptVerbose(config.SFA_API_LOGLEVEL)
-    if not config.SFA_REGISTRY_ENABLED:
-        logger.critical("COMMAND: need SFA_REGISTRY_ENABLED to run import")
-
-    # testbed-neutral : create local certificates and the like
-    auth_hierarchy = Hierarchy ()
-    sfa_importer = SfaImporter(auth_hierarchy, logger)
-    # testbed-specific
-    testbed_importer = None
-    generic=Generic.the_flavour()
-    importer_class = generic.importer_class()
-    if importer_class:
-        logger.info ("Using flavour %s for importing (class %s)"%\
-                         (generic.flavour,importer_class.__name__))
-        testbed_importer = importer_class (auth_hierarchy, logger)
-
-    parser = OptionParser ()
-    sfa_importer.add_options (parser)
-    if testbed_importer:
-        testbed_importer.add_options (parser)
-
-    (options, args) = parser.parse_args ()
-    # no args supported ?
-    if args:
-        parser.print_help()
-        sys.exit(1)
-
-    sfa_importer.run (options)
-    if testbed_importer:
-        testbed_importer.run (parser)
-    
-
-if __name__ == '__main__':
-    main()
-
diff --git a/sfa/importer/sfaimporter.py b/sfa/importer/sfaimporter.py
deleted file mode 100644 (file)
index 4f17c2d..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-#
-# Public keys are extracted from the users' SSH keys automatically and used to
-# create GIDs. This is relatively experimental as a custom tool had to be
-# written to perform conversion from SSH to OpenSSL format. It only supports
-# RSA keys at this time, not DSA keys.
-##
-
-from sfa.util.xrn import get_authority, hrn_to_urn
-from sfa.util.plxrn import email_to_hrn
-from sfa.util.config import Config
-from sfa.trust.certificate import convert_public_key, Keypair
-from sfa.trust.trustedroots import TrustedRoots
-from sfa.trust.gid import create_uuid
-
-from sfa.storage.alchemy import dbsession
-from sfa.storage.model import RegRecord, RegAuthority, RegUser
-
-def _un_unicode(str):
-   if isinstance(str, unicode):
-       return str.encode("ascii", "ignore")
-   else:
-       return str
-
-def _cleanup_string(str):
-    # pgsql has a fit with strings that have high ascii in them, so filter it
-    # out when generating the hrns.
-    tmp = ""
-    for c in str:
-        if ord(c) < 128:
-            tmp = tmp + c
-    str = tmp
-
-    str = _un_unicode(str)
-    str = str.replace(" ", "_")
-    str = str.replace(".", "_")
-    str = str.replace("(", "_")
-    str = str.replace("'", "_")
-    str = str.replace(")", "_")
-    str = str.replace('"', "_")
-    return str
-
-class SfaImporter:
-
-    def __init__(self, auth_hierarchy, logger):
-       self.logger=logger
-       self.auth_hierarchy = auth_hierarchy
-       config = Config()
-       self.TrustedRoots = TrustedRoots(Config.get_trustedroots_dir(config))
-       self.root_auth = config.SFA_REGISTRY_ROOT_AUTH
-       self.interface_hrn = config.SFA_INTERFACE_HRN
-
-    # check before creating a RegRecord entry as we run this over and over
-    def record_exists (self, type, hrn):
-       return dbsession.query(RegRecord).filter_by(hrn=hrn,type=type).count()!=0
-
-    # record options into an OptionParser
-    def add_options (self, parser):
-       # no generic option
-       pass
-
-    def run (self, options):
-       self.logger.info ("SfaImporter.run : no options used")
-       self.create_top_level_records()
-
-    def create_top_level_records(self):
-        """
-        Create top level and interface records
-        """
-        # create root authority
-        self.create_top_level_auth_records(self.interface_hrn)
-
-        # create s user record for the slice manager
-        self.create_sm_client_record()
-
-        # create interface records
-        # xxx turning off the creation of authority+*
-        # in fact his is required - used in SfaApi._getCredentialRaw
-        # that tries to locate 'authority+sa'
-        self.create_interface_records()
-
-        # add local root authority's cert  to trusted list
-        self.logger.info("SfaImporter: adding " + self.interface_hrn + " to trusted list")
-        authority = self.auth_hierarchy.get_auth_info(self.interface_hrn)
-        self.TrustedRoots.add_gid(authority.get_gid_object())
-
-    def create_top_level_auth_records(self, hrn):
-        """
-        Create top level db records (includes root and sub authorities (local/remote)
-        """
-        # make sure parent exists
-        parent_hrn = get_authority(hrn)
-        if not parent_hrn:
-            parent_hrn = hrn
-        if not parent_hrn == hrn:
-            self.create_top_level_auth_records(parent_hrn)
-
-        # ensure key and cert exists:
-        self.auth_hierarchy.create_top_level_auth(hrn)    
-        # create the db record if it doesnt already exist    
-        if self.record_exists ('authority',hrn): return
-        auth_info = self.auth_hierarchy.get_auth_info(hrn)
-        auth_record = RegAuthority(hrn=hrn, gid=auth_info.get_gid_object(),
-                                   authority=get_authority(hrn))
-        auth_record.just_created()
-        dbsession.add (auth_record)
-        dbsession.commit()
-        self.logger.info("SfaImporter: imported authority (parent) %s " % auth_record)
-
-    def create_sm_client_record(self):
-        """
-        Create a user record for the Slicemanager service.
-        """
-        hrn = self.interface_hrn + '.slicemanager'
-        urn = hrn_to_urn(hrn, 'user')
-        if not self.auth_hierarchy.auth_exists(urn):
-            self.logger.info("SfaImporter: creating Slice Manager user")
-            self.auth_hierarchy.create_auth(urn)
-
-        if self.record_exists ('user',hrn): return
-        auth_info = self.auth_hierarchy.get_auth_info(hrn)
-        user_record = RegUser(hrn=hrn, gid=auth_info.get_gid_object(),
-                              authority=get_authority(hrn))
-        user_record.just_created()
-        dbsession.add (user_record)
-        dbsession.commit()
-        self.logger.info("SfaImporter: importing user (slicemanager) %s " % user_record)
-
-    def create_interface_records(self):
-        """
-        Create a record for each SFA interface
-        """
-        # just create certs for all sfa interfaces even if they
-        # aren't enabled
-        auth_info = self.auth_hierarchy.get_auth_info(self.interface_hrn)
-        pkey = auth_info.get_pkey_object()
-        hrn=self.interface_hrn
-        for type in  [ 'authority+sa', 'authority+am', 'authority+sm', ]:
-            urn = hrn_to_urn(hrn, type)
-            gid = self.auth_hierarchy.create_gid(urn, create_uuid(), pkey)
-            # for now we have to preserve the authority+<> stuff
-            if self.record_exists (type,hrn): continue
-            interface_record = RegAuthority(type=type, hrn=hrn, gid=gid,
-                                            authority=get_authority(hrn))
-            interface_record.just_created()
-            dbsession.add (interface_record)
-            dbsession.commit()
-            self.logger.info("SfaImporter: imported authority (%s) %s " % (type,interface_record))
-