From 59a950678c0faa3cdbb227c11c761aee1da9c651 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Thu, 9 Jun 2011 13:29:31 -0400 Subject: [PATCH] add 'url' field to the authority record --- sfa/client/sfi.py | 4 ++-- sfa/plc/api.py | 43 ++++++++++++++++++++++------------------ sfa/trust/trustedroot.py | 2 -- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 4e77b24c..233f3a6b 100755 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -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): diff --git a/sfa/plc/api.py b/sfa/plc/api.py index 59ad1cb6..8e15ea79 100644 --- a/sfa/plc/api.py +++ b/sfa/plc/api.py @@ -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 diff --git a/sfa/trust/trustedroot.py b/sfa/trust/trustedroot.py index 2d4b89ef..ec8d2f05 100644 --- a/sfa/trust/trustedroot.py +++ b/sfa/trust/trustedroot.py @@ -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): -- 2.47.0