X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2Fget_gid.py;h=630221d02132268a5ca485529076cbb46f9e9654;hb=a8251f8a916e07b7c4fdf3b9e8280e64b9cd2da3;hp=66320e6badb58fd6afd2cd049d6a8662e665b5c1;hpb=9a1596f2dda68faf9a5ed8c51424fc9dc87c5c12;p=sfa.git diff --git a/sfa/methods/get_gid.py b/sfa/methods/get_gid.py index 66320e6b..630221d0 100644 --- a/sfa/methods/get_gid.py +++ b/sfa/methods/get_gid.py @@ -6,18 +6,20 @@ # raise ConnectionKeyGIDMismatch(gid.get_subject()) from sfa.util.faults import * +from sfa.util.namespace 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.util.genitable import GeniTable class get_gid(Method): """ Returns the client's gid if one exists @param cert certificate string + @param xrn human readable name (hrn or urn) + @param type object type @return client gid """ @@ -25,14 +27,20 @@ class get_gid(Method): accepts = [ Parameter(str, "Certificate string"), - Parameter(str, "Human readable name (hrn)"), + Parameter(str, "Human readable name (hrn or urn)"), Parameter(str, "Object type") ] returns = Parameter(str, "GID string") - def call(self, cert, hrn, type): - + def call(self, cert, xrn, type): + + # convert xrn to hrn + if type: + hrn = urn_to_hrn(xrn)[0] + else: + hrn, type = urn_to_hrn(xrn) + self.api.auth.verify_object_belongs_to_me(hrn) # resolve the record @@ -40,7 +48,7 @@ class get_gid(Method): 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, hrn, type, origin_hrn=hrn) + records = manager.resolve(self.api, xrn, type, origin_hrn=hrn) if not records: raise RecordNotFound(hrn) record = records[0]