X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fimporter%2FsfaImport.py;h=3f054ba70d1815c21dba016207bbe9e4f2eabb06;hb=9b9ffbbb64ae96d969005cffd1d65aa993731f56;hp=4de6e1bd6d4ee41c925e38f2ed544ccc581b2b28;hpb=3549fbaaa75ad8244d64ad631ae893a0afa54421;p=sfa.git diff --git a/sfa/importer/sfaImport.py b/sfa/importer/sfaImport.py index 4de6e1bd..3f054ba7 100644 --- a/sfa/importer/sfaImport.py +++ b/sfa/importer/sfaImport.py @@ -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,23 +53,17 @@ 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): """ - Create top level records (includes root and sub authorities (local/remote) + Create top level db records (includes root and sub authorities (local/remote) """ - urn = hrn_to_urn(hrn, 'authority') # make sure parent exists parent_hrn = get_authority(hrn) if not parent_hrn: @@ -76,11 +71,8 @@ class sfaImport: if not parent_hrn == hrn: self.create_top_level_auth_records(parent_hrn) - # create the authority if it doesnt already exist - if not self.AuthHierarchy.auth_exists(urn): - self.logger.info("Import: creating top level authorities") - self.AuthHierarchy.create_auth(urn) - + # 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() @@ -149,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: