From: Tony Mack Date: Fri, 6 Aug 2010 21:11:17 +0000 (+0000) Subject: Replacing get_gids with GetGids X-Git-Tag: sfa-1.0-0~71 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=0bbb342d0356ef47609e33e6a4783411aa246395;p=sfa.git Replacing get_gids with GetGids --- diff --git a/sfa/methods/GetGids.py b/sfa/methods/GetGids.py index b4976701..37ad7967 100644 --- a/sfa/methods/GetGids.py +++ b/sfa/methods/GetGids.py @@ -6,7 +6,7 @@ from sfa.trust.gid import GID from sfa.trust.certificate import Certificate from sfa.trust.credential import Credential -class get_gids(Method): +class GetGids(Method): """ Get a list of record information (hrn, gid and type) for the specified hrns. @@ -19,25 +19,22 @@ class get_gids(Method): interfaces = ['registry'] accepts = [ - Parameter(str, "Certificate string"), Mixed(Parameter(str, "Human readable name (hrn or xrn)"), - Parameter(type([str]), "List of Human readable names (hrn or xrn)")) + Parameter(type([str]), "List of Human readable names (hrn or xrn)")), + Mixed(Parameter(str, "Credential string"), + Parameter(type([str]), "List of credentials")), ] returns = [Parameter(dict, "Dictionary of gids keyed on hrn")] - def call(self, cred, xrns): + def call(self, xrns, creds): # validate the credential - self.api.auth.check(cred, 'getgids') - user_cred = Credential(string=cred) - origin_hrn = user_cred.get_gid_caller().get_hrn() - + valid_creds = self.api.auth.checkCredentials(creds, 'getgids') + origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn() + # resolve the record - manager_base = 'sfa.managers' - mgr_type = self.api.config.SFA_REGISTRY_TYPE - manager_module = manager_base + ".registry_manager_%s" % mgr_type - manager = __import__(manager_module, fromlist=[manager_base]) - records = manager.resolve(self.api, xrns, None, origin_hrn=origin_hrn, full = False) + manager = self.api.get_interface_manager() + records = manager.resolve(self.api, xrns, full = False) if not records: raise RecordNotFound(hrns) diff --git a/sfa/methods/get_gids.py b/sfa/methods/get_gids.py index b4976701..c54af0a3 100644 --- a/sfa/methods/get_gids.py +++ b/sfa/methods/get_gids.py @@ -1,13 +1,12 @@ from sfa.util.faults import * from sfa.util.method import Method from sfa.util.parameter import Parameter, Mixed -from sfa.trust.auth import Auth -from sfa.trust.gid import GID -from sfa.trust.certificate import Certificate -from sfa.trust.credential import Credential +from sfa.methods.GetGids import GetGids -class get_gids(Method): +class get_gids(GetGids): """ + Deprecated. Use GetGids instead. + Get a list of record information (hrn, gid and type) for the specified hrns. @@ -27,24 +26,5 @@ class get_gids(Method): returns = [Parameter(dict, "Dictionary of gids keyed on hrn")] def call(self, cred, xrns): - # validate the credential - self.api.auth.check(cred, 'getgids') - user_cred = Credential(string=cred) - origin_hrn = user_cred.get_gid_caller().get_hrn() - - # resolve the record - manager_base = 'sfa.managers' - mgr_type = self.api.config.SFA_REGISTRY_TYPE - manager_module = manager_base + ".registry_manager_%s" % mgr_type - manager = __import__(manager_module, fromlist=[manager_base]) - records = manager.resolve(self.api, xrns, None, origin_hrn=origin_hrn, full = False) - if not records: - raise RecordNotFound(hrns) - - gids = [] - allowed_fields = ['hrn', 'type', 'gid'] - for record in records: - for key in record.keys(): - if key not in allowed_fields: - del(record[key]) - return records + + return GetGids.call(self, xrns, cred)