create registry objects with kdws-style again, like RegAuthority(hrn=hrn)
[sfa.git] / sfa / importer / sfaimporter.py
index 00e9908..bc1ea0a 100644 (file)
@@ -48,8 +48,8 @@ class SfaImporter:
        self.root_auth = self.config.SFA_REGISTRY_ROOT_AUTH
 
     # record options into an OptionParser
-    def record_options (self, parser):
-       self.logger.info ("SfaImporter.record_options : to do")
+    def add_options (self, parser):
+       # no generic option
        pass
 
     def run (self, options):
@@ -68,14 +68,14 @@ class SfaImporter:
         self.create_sm_client_record()
 
         # create interface records
-        self.logger.info("Import: creating interface records")
+        self.logger.info("SfaImporter: creating interface records")
 # xxx authority+ 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("Import: adding " + interface_hrn + " to trusted list")
+        self.logger.info("SfaImporter: adding " + interface_hrn + " to trusted list")
         authority = self.auth_hierarchy.get_auth_info(interface_hrn)
         self.TrustedRoots.add_gid(authority.get_gid_object())
 
@@ -94,15 +94,12 @@ class SfaImporter:
         self.auth_hierarchy.create_top_level_auth(hrn)    
         # create the db record if it doesnt already exist    
         auth_info = self.auth_hierarchy.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)
+        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("Import: imported authority (parent) %s " % auth_record)
+        self.logger.info("SfaImporter: imported authority (parent) %s " % auth_record)
 
     def create_sm_client_record(self):
         """
@@ -111,19 +108,16 @@ class SfaImporter:
         hrn = self.config.SFA_INTERFACE_HRN + '.slicemanager'
         urn = hrn_to_urn(hrn, 'user')
         if not self.auth_hierarchy.auth_exists(urn):
-            self.logger.info("Import: creating Slice Manager user")
+            self.logger.info("SfaImporter: creating Slice Manager user")
             self.auth_hierarchy.create_auth(urn)
 
         auth_info = self.auth_hierarchy.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)
+        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("Import: importing user (slicemanager) %s " % user_record)
+        self.logger.info("SfaImporter: importing user (slicemanager) %s " % user_record)
 
     def create_interface_records(self):
         """
@@ -139,15 +133,12 @@ class SfaImporter:
             gid = self.auth_hierarchy.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 = RegAuthority()
-            interface_record.type=type
-            interface_record.hrn=hrn
-            interface_record.gid= gid
-            interface_record.authority=get_authority(hrn)
+            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("Import: imported authority (%s) %s " % (type,interface_record))
+            self.logger.info("SfaImporter: imported authority (%s) %s " % (type,interface_record))
              
     def delete_record(self, hrn, type):
         # delete the record