the Resolve method takes an optional argument that tells if we need
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 19 Sep 2012 14:49:48 +0000 (16:49 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 19 Sep 2012 14:49:48 +0000 (16:49 +0200)
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
sfa/client/sfi.py
sfa/managers/driver.py
sfa/managers/registry_manager.py
sfa/methods/GetGids.py
sfa/methods/GetSelfCredential.py
sfa/methods/Resolve.py

index 12aa15d..ffe7a4b 100755 (executable)
@@ -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) 
index 3695f9a..067fd9c 100644 (file)
@@ -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:
index d6a81be..f049f54 100644 (file)
@@ -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
 
index f3f75f7..407e779 100644 (file)
@@ -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
index f67f5d4..623fbe9 100644 (file)
@@ -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)
 
index c67bf4b..aa53def 100644 (file)
@@ -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)
 
index 7abc6cd..6a32344 100644 (file)
@@ -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)