Changeset 65f3f29 for fedd/federation


Ignore:
Timestamp:
Jul 25, 2009 10:52:45 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
ca489e8
Parents:
d27fd76
Message:

Added multi info functions and some helpers to fedd_client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    rd27fd76 r65f3f29  
    329329                'Vis': soap_handler('Vis', self.get_vis),
    330330                'Info': soap_handler('Info', self.get_info),
     331                'MultiInfo': soap_handler('MultiInfo', self.get_multi_info),
    331332                'Terminate': soap_handler('Terminate',
    332333                    self.terminate_experiment),
     
    338339                'Vis': xmlrpc_handler('Vis', self.get_vis),
    339340                'Info': xmlrpc_handler('Info', self.get_info),
     341                'MultiInfo': xmlrpc_handler('MultiInfo', self.get_multi_info),
    340342                'Terminate': xmlrpc_handler('Terminate',
    341343                    self.terminate_experiment),
     
    21772179                raise service_error(service_error.req, "No such experiment")
    21782180
     2181    def clean_info_response(self, rv):
     2182        """
     2183        Remove the information in the experiment's state object that is not in
     2184        the info response.
     2185        """
     2186        # Remove the owner info (should always be there, but...)
     2187        if rv.has_key('owner'): del rv['owner']
     2188
     2189        # Convert the log into the allocationLog parameter and remove the
     2190        # log entry (with defensive programming)
     2191        if rv.has_key('log'):
     2192            rv['allocationLog'] = "".join(rv['log'])
     2193            del rv['log']
     2194        else:
     2195            rv['allocationLog'] = ""
     2196
     2197        if rv['experimentStatus'] != 'active':
     2198            if rv.has_key('federant'): del rv['federant']
     2199        else:
     2200            # remove the allocationID info from each federant
     2201            for f in rv.get('federant', []):
     2202                if f.has_key('allocID'): del f['allocID']
     2203
     2204        return rv
     2205
    21792206    def get_info(self, req, fid):
    21802207        """
     
    21862213        if not req:
    21872214            raise service_error(service_error.req,
    2188                     "Bad request format (no VisRequestBody)")
     2215                    "Bad request format (no InfoRequestBody)")
    21892216        exp = req.get('experiment', None)
    21902217        if exp:
     
    22112238
    22122239        if rv:
    2213             # Remove the owner info (should always be there, but...)
    2214             if rv.has_key('owner'): del rv['owner']
    2215 
    2216             # Convert the log into the allocationLog parameter and remove the
    2217             # log entry (with defensive programming)
    2218             if rv.has_key('log'):
    2219                 rv['allocationLog'] = "".join(rv['log'])
    2220                 del rv['log']
    2221             else:
    2222                 rv['allocationLog'] = ""
    2223 
    2224             if rv['experimentStatus'] != 'active':
    2225                 if rv.has_key('federant'): del rv['federant']
    2226             else:
    2227                 # remove the allocationID info from each federant
    2228                 for f in rv.get('federant', []):
    2229                     if f.has_key('allocID'): del f['allocID']
    2230 
    2231             return rv
     2240            return self.clean_info_response(rv)
    22322241        else:
    22332242            raise service_error(service_error.req, "No such experiment")
     2243
     2244    def get_multi_info(self, req, fid):
     2245        """
     2246        Return all the stored info that this fedid can access
     2247        """
     2248        rv = { 'info': [ ] }
     2249
     2250        self.state_lock.acquire()
     2251        for key in [ k for k in self.state.keys() if isinstance(k, fedid)]:
     2252            self.check_experiment_access(fid, key)
     2253
     2254            if self.state.has_key(key):
     2255                e = copy.deepcopy(self.state[key])
     2256                e = self.clean_info_response(e)
     2257                rv['info'].append(e)
     2258        self.state_lock.release()
     2259        return rv
    22342260
    22352261
Note: See TracChangeset for help on using the changeset viewer.