From ec119c68825b2b16a249d120422739e3f7b32a9d Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 19 Sep 2012 16:49:48 +0200 Subject: [PATCH] the Resolve method takes an optional argument that tells if we need details from the testbed (which was named 'full', which was dumb, I renamed this as 'details') in any case this change is about using details=False by default, as SFA data should be self-sufficient, and examples of foreign drivers have shown the problem... --- sfa/client/sfaadmin.py | 2 +- sfa/client/sfi.py | 2 ++ sfa/managers/driver.py | 8 +++----- sfa/managers/registry_manager.py | 11 +++++++---- sfa/methods/GetGids.py | 2 +- sfa/methods/GetSelfCredential.py | 2 +- sfa/methods/Resolve.py | 5 ++++- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/sfa/client/sfaadmin.py b/sfa/client/sfaadmin.py index 12aa15d6..ffe7a4bf 100755 --- a/sfa/client/sfaadmin.py +++ b/sfa/client/sfaadmin.py @@ -69,7 +69,7 @@ class RegistryCommands(Commands): choices=('text', 'xml', 'simple'), help='display record in different formats') def show(self, xrn, type=None, format=None, outfile=None): """Display details for a registered object""" - records = self.api.manager.Resolve(self.api, xrn, type, True) + records = self.api.manager.Resolve(self.api, xrn, type, details=True) for record in records: sfa_record = Record(dict=record) sfa_record.dump(format) diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 3695f9a2..067fd9c1 100644 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -872,6 +872,8 @@ or version information about sfi itself self.print_help() sys.exit(1) hrn = args[0] + # xxx should set details=True here but that's not in the xmlrpc interface ... + # record_dicts = self.registry().Resolve(hrn, self.my_credential_string, details=True) record_dicts = self.registry().Resolve(hrn, self.my_credential_string) record_dicts = filter_records(options.type, record_dicts) if not record_dicts: diff --git a/sfa/managers/driver.py b/sfa/managers/driver.py index d6a81be0..f049f549 100644 --- a/sfa/managers/driver.py +++ b/sfa/managers/driver.py @@ -20,11 +20,9 @@ class Driver: # the following is used in Resolve (registry) when run in full mode # after looking up the sfa db, we wish to be able to display # testbed-specific info as well - # this at minima should fill in the 'researcher' field for slice records - # as this information is then used to compute rights - # roadmap: there is an intention to redesign the SFA database so as to clear up - # this constraint, based on the principle that SFA should not rely on the - # testbed database to perform such a core operation (i.e. getting rights right) + # based on the principle that SFA should not rely on the testbed database + # to perform such a core operation (i.e. getting rights right) + # this is no longer in use when performing other SFA operations def augment_records_with_testbed_info (self, sfa_records): return sfa_records diff --git a/sfa/managers/registry_manager.py b/sfa/managers/registry_manager.py index f3f75f79..407e7791 100644 --- a/sfa/managers/registry_manager.py +++ b/sfa/managers/registry_manager.py @@ -104,7 +104,8 @@ class RegistryManager: return new_cred.save_to_string(save_parents=True) - def Resolve(self, api, xrns, type=None, full=True): + # the default for full, which means 'dig into the testbed as well', should be false + def Resolve(self, api, xrns, type=None, details=False): if not isinstance(xrns, types.ListType): # try to infer type if not set and we get a single input @@ -142,6 +143,8 @@ class RegistryManager: credential = api.getCredential() interface = api.registries[registry_hrn] server_proxy = api.server_proxy(interface, credential) + # should propagate the details flag but that's not supported in the xmlrpc interface yet + #peer_records = server_proxy.Resolve(xrns, credential,type, details=details) peer_records = server_proxy.Resolve(xrns, credential,type) # pass foreign records as-is # previous code used to read @@ -156,11 +159,11 @@ class RegistryManager: if type: local_records = local_records.filter_by(type=type) local_records=local_records.all() - logger.info("Resolve: local_records=%s (type=%s)"%(local_records,type)) + logger.info("Resolve details=%s: local_records=%s (type=%s)"%(details,local_records,type)) local_dicts = [ record.__dict__ for record in local_records ] - if full: - # in full mode we get as much info as we can, which involves contacting the + if details: + # in details mode we get as much info as we can, which involves contacting the # testbed for getting implementation details about the record self.driver.augment_records_with_testbed_info(local_dicts) # also we fill the 'url' field for known authorities diff --git a/sfa/methods/GetGids.py b/sfa/methods/GetGids.py index f67f5d4d..623fbe92 100644 --- a/sfa/methods/GetGids.py +++ b/sfa/methods/GetGids.py @@ -33,7 +33,7 @@ class GetGids(Method): origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn() # resolve the record - records = self.api.manager.Resolve(self.api, xrns, full = False) + records = self.api.manager.Resolve(self.api, xrns, details = False) if not records: raise RecordNotFound(xrns) diff --git a/sfa/methods/GetSelfCredential.py b/sfa/methods/GetSelfCredential.py index c67bf4be..aa53defb 100644 --- a/sfa/methods/GetSelfCredential.py +++ b/sfa/methods/GetSelfCredential.py @@ -63,7 +63,7 @@ class GetSelfCredential(Method): # another registry if needed # I wonder if this is truly the intention, or shouldn't we instead # only look in the local db ? - records = self.api.manager.Resolve(self.api, xrn, type) + records = self.api.manager.Resolve(self.api, xrn, type, details=False) if not records: raise RecordNotFound(hrn) diff --git a/sfa/methods/Resolve.py b/sfa/methods/Resolve.py index 7abc6cda..6a323440 100644 --- a/sfa/methods/Resolve.py +++ b/sfa/methods/Resolve.py @@ -18,6 +18,7 @@ class Resolve(Method): interfaces = ['registry'] + # should we not accept an optional 'details' argument ? accepts = [ Mixed(Parameter(str, "Human readable name (hrn or urn)"), Parameter(list, "List of Human readable names ([hrn])")), @@ -29,6 +30,8 @@ class Resolve(Method): returns = [Parameter(dict, "registry record")] def call(self, xrns, creds): + # xxx should be ar arg + details=False type = None if not isinstance(xrns, types.ListType): type = Xrn(xrns).get_type() @@ -42,5 +45,5 @@ class Resolve(Method): self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name)) # send the call to the right manager - return self.api.manager.Resolve(self.api, xrns, type) + return self.api.manager.Resolve(self.api, xrns, type, details=details) -- 2.43.0