add 'url' field to the authority record
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 9 Jun 2011 17:29:31 +0000 (13:29 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 9 Jun 2011 17:29:31 +0000 (13:29 -0400)
sfa/client/sfi.py
sfa/plc/api.py
sfa/trust/trustedroot.py

index 4e77b24..233f3a6 100755 (executable)
@@ -678,7 +678,7 @@ class Sfi:
                 record = SliceRecord(dict=record)
             elif record['type'] in ['node']:
                 record = NodeRecord(dict=record)
-            elif record['type'] in ['authority', 'ma', 'sa']:
+            elif record['type'].startswith('authority'):
                 record = AuthorityRecord(dict=record)
             else:
                 record = SfaRecord(dict=record)
@@ -686,7 +686,7 @@ class Sfi:
                 record.dump()  
             else:
                 print record.save_to_string() 
-       
         if opts.file:
             file = opts.file
             if not file.startswith(os.sep):
index 59ad1cb..8e15ea7 100644 (file)
@@ -477,8 +477,8 @@ class SfaAPI(BaseAPI):
         # fill sfa info
         for record in records:
             # skip records with no pl info (top level authorities)
-            if record['pointer'] == -1:
-                continue 
+            #if record['pointer'] == -1:
+            #    continue 
             sfa_info = {}
             type = record['type']
             if (type == "slice"):
@@ -499,23 +499,28 @@ class SfaAPI(BaseAPI):
                         record['PI'].extend(hrns)
                         record['geni_creator'] = record['PI'] 
                 
-            elif (type == "authority"):
-                record['PI'] = []
-                record['operator'] = []
-                record['owner'] = []
-                for pointer in record['person_ids']:
-                    if pointer not in persons or pointer not in pl_persons:
-                        # this means there is not sfa or pl record for this user
-                        continue   
-                    hrns = [person['hrn'] for person in persons[pointer]] 
-                    roles = pl_persons[pointer]['roles']   
-                    if 'pi' in roles:
-                        record['PI'].extend(hrns)
-                    if 'tech' in roles:
-                        record['operator'].extend(hrns)
-                    if 'admin' in roles:
-                        record['owner'].extend(hrns)
-                    # xxx TODO: OrganizationName
+            elif (type.startswith("authority")):
+                record['url'] = None
+                if record['hrn'] in self.aggregates:
+                    record['url'] = self.aggregates[record['hrn']].url
+
+                if record['pointer'] != -1:
+                    record['PI'] = []
+                    record['operator'] = []
+                    record['owner'] = []
+                    for pointer in record.get('person_ids', []):
+                        if pointer not in persons or pointer not in pl_persons:
+                            # this means there is not sfa or pl record for this user
+                            continue   
+                        hrns = [person['hrn'] for person in persons[pointer]] 
+                        roles = pl_persons[pointer]['roles']   
+                        if 'pi' in roles:
+                            record['PI'].extend(hrns)
+                        if 'tech' in roles:
+                            record['operator'].extend(hrns)
+                        if 'admin' in roles:
+                            record['owner'].extend(hrns)
+                        # xxx TODO: OrganizationName
             elif (type == "node"):
                 sfa_info['dns'] = record.get("hostname", "")
                 # xxx TODO: URI, LatLong, IP, DNS
index 2d4b89e..ec8d2f0 100644 (file)
@@ -24,14 +24,12 @@ class TrustedRootList:
 
     def get_list(self):
         gid_list = []
-
         file_list = os.listdir(self.basedir)
         for gid_file in file_list:
             fn = os.path.join(self.basedir, gid_file)
             if os.path.isfile(fn):
                 gid = GID(filename = fn)
                 gid_list.append(gid)
-
         return gid_list
 
     def get_file_list(self):