- # load all know registry names into a prefix tree and attempt to find
- # the longest matching prefix
- registries = Registries(self.api)
- hrns = registries.keys()
- tree = prefixTree()
- tree.load(hrns)
- registry_hrn = tree.best_match(hrn)
-
- #if there was no match then this record belongs to an unknow registry
- if not registry_hrn:
- raise MissingAuthority(hrn)
-
- # if the best match (longest matching hrn) is not the local registry,
- # forward the request
- if registry_hrn != self.api.hrn:
- credential = self.api.getCredential()
- try:
- records = registries[registry_hrn].resolve(credential, hrn, caller_cred=caller_cred)
- good_records = [record.as_dict() for record in records]
- if good_records:
- return good_records
- except:
- traceback.print_exc()
-
- # if we still havnt found the record yet, try the local registry
- table = GeniTable()
- records = table.find(hrn)
- if not records:
- raise RecordNotFound(hrn)
- for record in records:
- try:
- self.api.fill_record_info(record)
- good_records.append(dict(record))
- except PlanetLabRecordDoesNotExist:
- # silently drop the ones that are missing in PL
- print >> log, "ignoring geni record ", record.get_name(), \
- " because pl record does not exist"
- table.remove(record)
-
-
- return good_records