Merge branch 'master' of ssh://bakers@git.planet-lab.org/git/sfa
[sfa.git] / sfa / importer / sfaImport.py
index 4c5b5c7..3f054ba 100644 (file)
@@ -9,17 +9,18 @@
 ##
 
 from sfa.util.sfalogging import _SfaLogger
-
-from sfa.util.record import SfaRecord
-from sfa.util.table import SfaTable
 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.hierarchy import Hierarchy
 from sfa.trust.gid import create_uuid
 
+from sfa.storage.record import SfaRecord
+from sfa.storage.table import SfaTable
+
 
 def _un_unicode(str):
    if isinstance(str, unicode):
@@ -52,17 +53,12 @@ class sfaImport:
        self.AuthHierarchy = Hierarchy()
        self.config = Config()
        self.TrustedRoots = TrustedRoots(Config.get_trustedroots_dir(self.config))
-       self.plc_auth = self.config.get_plc_auth()
        self.root_auth = self.config.SFA_REGISTRY_ROOT_AUTH
         
-       # connect to planetlab
-       self.shell = None
-       if "Url" in self.plc_auth:
-          from sfa.plc.remoteshell import RemoteShell
-          self.shell = RemoteShell(self.logger)
-       else:
-          import PLC.Shell
-          self.shell = PLC.Shell.Shell(globals = globals())        
+       # should use a driver instead...
+       from sfa.plc.plshell import PlShell
+       # how to connect to planetlab 
+       self.shell = PlShell (self.config)
 
     def create_top_level_auth_records(self, hrn):
         """
@@ -75,6 +71,8 @@ class sfaImport:
         if not parent_hrn == hrn:
             self.create_top_level_auth_records(parent_hrn)
 
+        # enxure key and cert exists:
+        self.AuthHierarchy.create_top_level_auth(hrn)    
         # create the db record if it doesnt already exist    
         auth_info = self.AuthHierarchy.get_auth_info(hrn)
         table = SfaTable()
@@ -143,7 +141,7 @@ class sfaImport:
             key_ids = person["key_ids"]
             # get the user's private key from the SSH keys they have uploaded
             # to planetlab
-            keys = self.shell.GetKeys(self.plc_auth, key_ids)
+            keys = self.shell.GetKeys(key_ids)
             key = keys[0]['key']
             pkey = None
             try: