4 from geni.util.faults import *
5 from geni.util.method import Method
6 from geni.util.parameter import Parameter, Mixed
7 from geni.util.auth import Auth
8 from geni.util.record import GeniRecord
9 from geni.registry import Registries
10 from geni.util.debug import log
12 class resolve(Method):
16 @param cred credential string authorizing the caller
17 @param hrn human readable name to resolve
18 @return a list of record dictionaries or empty list
21 interfaces = ['registry']
24 Parameter(str, "Credential string"),
25 Parameter(str, "Human readable name (hrn)")
28 returns = [GeniRecord]
30 def call(self, cred, hrn):
32 self.api.auth.check(cred, 'resolve')
35 auth_hrn = self.api.auth.get_authority(hrn)
38 table = self.api.auth.get_auth_table(auth_hrn)
39 records = table.resolve('*', hrn)
41 raise RecordNotFound(hrn)
43 for record in records:
45 self.api.fill_record_info(record)
46 good_records.append(record)
47 except PlanetLabRecordDoesNotExist:
48 # silently drop the ones that are missing in PL
49 print >> log, "ignoring geni record ", record.get_name(), \
50 " because pl record does not exist"
53 # is this a foreign record
54 registries = Registries(self.api)
55 credential = self.api.getCredential()
56 for registry in registries:
57 if hrn.startswith(registry) and not registry in [self.api.hrn]:
58 records = registries[registry].resolve(credential, hrn)
59 good_records = records
60 dicts = [record.as_dict() for record in good_records]