add another column in RegRecord, separate from 'type' to act as a discriminator
[sfa.git] / sfa / importer / sfaImport.py
index 8d09b81..a9d6bd7 100644 (file)
@@ -17,7 +17,6 @@ from sfa.trust.trustedroots import TrustedRoots
 from sfa.trust.hierarchy import Hierarchy
 from sfa.trust.gid import create_uuid
 from sfa.storage.persistentobjs import RegRecord, RegAuthority, RegUser
-from sfa.storage.persistentobjs import RegAuthoritySa, RegAuthorityAm, RegAuthoritySm
 from sfa.storage.alchemy import dbsession
 
 def _un_unicode(str):
@@ -92,6 +91,7 @@ class sfaImport:
         # create the db record if it doesnt already exist    
         auth_info = self.AuthHierarchy.get_auth_info(hrn)
         auth_record = RegAuthority()
+        auth_record.type='authority'
         auth_record.hrn=hrn
         auth_record.gid=auth_info.get_gid_object()
         auth_record.authority=get_authority(hrn)
@@ -112,6 +112,7 @@ class sfaImport:
 
         auth_info = self.AuthHierarchy.get_auth_info(hrn)
         user_record = RegUser()
+        user_record.type='user'
         user_record.hrn=hrn
         user_record.gid=auth_info.get_gid_object()
         user_record.authority=get_authority(hrn)
@@ -127,17 +128,15 @@ class sfaImport:
         # just create certs for all sfa interfaces even if they
         # aren't enabled
         hrn = self.config.SFA_INTERFACE_HRN
-        reg_classes_info = [ (RegAuthoritySa, 'authority+sa'),
-                          (RegAuthorityAm, 'authority+am'),
-                          (RegAuthoritySm, 'authority+sm'), ]
         auth_info = self.AuthHierarchy.get_auth_info(hrn)
         pkey = auth_info.get_pkey_object()
-        for (reg_class, type) in reg_classes_info:
+        for type in  [ 'authority+sa', 'authority+am', 'authority+sm', ]:
             urn = hrn_to_urn(hrn, type)
             gid = self.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
             # xxx this should probably use a RegAuthority, or a to-be-defined RegPeer object
             # but for now we have to preserve the authority+<> stuff
-            interface_record = reg_class()
+            interface_record = RegAuthority()
+            interface_record.type=type
             interface_record.hrn=hrn
             interface_record.gid= gid
             interface_record.authority=get_authority(hrn)