namespace module is gone, plxrn provides PL-specific translations
[sfa.git] / sfa / plc / sfa-import-plc.py
index 814fffa..637109a 100755 (executable)
 import getopt
 import sys
 import tempfile
-import logging
 
 from sfa.util.record import *
 from sfa.util.table import SfaTable
-from sfa.util.namespace import *
+from sfa.util.xrn import get_leaf, get_authority
+from sfa.util.plxrn import hostname_to_hrn, slicename_to_hrn, email_to_hrn, hrn_to_pl_slicename
 from sfa.util.config import Config
 from sfa.trust.certificate import convert_public_key, Keypair
 from sfa.trust.trustedroot import *
@@ -31,7 +31,6 @@ from sfa.trust.gid import create_uuid
 from sfa.plc.sfaImport import sfaImport
 
 def process_options():
-   global hrn
 
    (options, args) = getopt.getopt(sys.argv[1:], '', [])
    for opt in options:
@@ -65,11 +64,9 @@ def main():
     interface_hrn = config.SFA_INTERFACE_HRN
     keys_filename = config.config_path + os.sep + 'person_keys.py' 
     sfaImporter = sfaImport()
-    if config.SFA_API_DEBUG: sfaImporter.logger.setLevel(logging.DEBUG)
+    if config.SFA_API_DEBUG: sfaImporter.logger.setLevelDebug()
     shell = sfaImporter.shell
     plc_auth = sfaImporter.plc_auth 
-    AuthHierarchy = sfaImporter.AuthHierarchy
-    TrustedRoots = sfaImporter.TrustedRoots
     table = SfaTable()
 
     if not table.exists():
@@ -81,8 +78,8 @@ def main():
         sfaImporter.create_top_level_auth_records(interface_hrn)
 
     sfaImporter.logger.info("Import: adding " + interface_hrn + " to trusted list")
-    authority = AuthHierarchy.get_auth_info(interface_hrn)
-    TrustedRoots.add_gid(authority.get_gid_object())
+    authority = sfaImporter.AuthHierarchy.get_auth_info(interface_hrn)
+    sfaImporter.TrustedRoots.add_gid(authority.get_gid_object())
 
     if ".vini" in interface_hrn and interface_hrn.endswith('vini'):
         # create a fake internet2 site first
@@ -141,7 +138,7 @@ def main():
     # start importing 
     for site in sites:
         site_hrn = interface_hrn + "." + site['login_base']
-        print "Importing site: %s" % site_hrn
+        sfa_logger().info("Importing site: %s" % site_hrn)
 
         # import if hrn is not in list of existing hrns or if the hrn exists
         # but its not a site record