1 from sfa.util.faults import *
2 from sfa.util.method import Method
3 from sfa.util.parameter import Parameter, Mixed
4 from sfa.trust.auth import Auth
5 from sfa.trust.gid import GID
6 from sfa.trust.certificate import Certificate
7 from sfa.trust.credential import Credential
9 class get_gids(Method):
11 Get a list of record information (hrn, gid and type) for
14 @param cred credential string
15 @param cert certificate string
19 interfaces = ['registry']
22 Parameter(str, "Certificate string"),
23 Mixed(Parameter(str, "Human readable name (hrn or xrn)"),
24 Parameter(type([str]), "List of Human readable names (hrn or xrn)"))
27 returns = [Parameter(dict, "Dictionary of gids keyed on hrn")]
29 def call(self, cred, xrns):
30 # validate the credential
31 self.api.auth.check(cred, 'getgids')
32 user_cred = Credential(string=cred)
33 origin_hrn = user_cred.get_gid_caller().get_hrn()
36 manager_base = 'sfa.managers'
37 mgr_type = self.api.config.SFA_REGISTRY_TYPE
38 manager_module = manager_base + ".registry_manager_%s" % mgr_type
39 manager = __import__(manager_module, fromlist=[manager_base])
40 records = manager.resolve(self.api, xrns, None, origin_hrn=origin_hrn, full = False)
42 raise RecordNotFound(hrns)
45 allowed_fields = ['hrn', 'type', 'gid']
46 for record in records:
47 for key in record.keys():
48 if key not in allowed_fields: