belongs with previous change
[sfa.git] / sfa / importer / plimporter.py
index c320482..aa1110d 100644 (file)
@@ -193,7 +193,7 @@ class PlImporter:
         self.create_special_vini_record (interface_hrn)
 
         # Get top authority record
-        top_auth_record=self.locate_by_type_hrn ('authority', root_auth)
+        top_auth_record = self.locate_by_type_hrn ('authority', root_auth)
         admins = []
 
         # start importing 
@@ -209,7 +209,7 @@ class PlImporter:
             site_hrn = site['hrn']
             # import if hrn is not in list of existing hrns or if the hrn exists
             # but its not a site record
-            site_record=self.locate_by_type_hrn ('authority', site_hrn)
+            site_record = self.locate_by_type_hrn ('authority', site_hrn)
             if not site_record:
                 try:
                     urn = hrn_to_urn(site_hrn, 'authority')
@@ -218,7 +218,8 @@ class PlImporter:
                     auth_info = self.auth_hierarchy.get_auth_info(urn)
                     site_record = RegAuthority(hrn=site_hrn, gid=auth_info.get_gid_object(),
                                                pointer=site['site_id'],
-                                               authority=get_authority(site_hrn))
+                                               authority=get_authority(site_hrn),
+                                               name=site['name'])
                     site_record.just_created()
                     global_dbsession.add(site_record)
                     global_dbsession.commit()
@@ -231,6 +232,7 @@ class PlImporter:
                     continue 
             else:
                 # xxx update the record ...
+                site_record.name = site['name']
                 pass
             site_record.stale=False
              
@@ -284,6 +286,9 @@ class PlImporter:
 
                 #person_hrn = email_to_hrn(site_hrn, person['email'])
                 person_hrn = person['hrn']
+                if person_hrn is None:
+                    self.logger.warn("Person %s has no hrn - skipped"%person['email'])
+                    continue
                 # xxx suspicious again
                 if len(person_hrn) > 64: person_hrn = person_hrn[:64]
                 person_urn = hrn_to_urn(person_hrn, 'user')
@@ -405,6 +410,9 @@ class PlImporter:
                     continue
                 #slice_hrn = slicename_to_hrn(interface_hrn, slice['name'])
                 slice_hrn = slice['hrn']
+                if slice_hrn is None:
+                    self.logger.warning("Slice %s has no hrn - skipped"%slice['name'])
+                    continue
                 slice_record = self.locate_by_type_hrn ('slice', slice_hrn)
                 if not slice_record:
                     try: