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