Ignore:
Timestamp:
Nov 21, 2011 5:33:41 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
f769cb3
Parents:
80b1e82
Message:

Turn (most) of another free floating dict into a class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    r80b1e82 r9294673  
    960960            tb_attrs = copy.copy(attrs)
    961961            tp.wait_for_slot()
    962             uri = tbparams[tb].get('uri', tbmap.get(testbed_base(tb), None))
     962            uri = tbparams[tb].uri or tbmap.get(testbed_base(tb), None)
    963963            base, suffix = split_testbed(tb)
    964964            if suffix:
     
    971971                        "Unknown testbed %s !?" % tb)
    972972
    973             if tbparams[tb].has_key('allocID') and \
    974                     tbparams[tb]['allocID'].has_key('fedid'):
    975                 aid = tbparams[tb]['allocID']['fedid']
    976             else:
     973            aid = tbparams[tb].allocID
     974            if not aid:
    977975                raise service_error(service_error.internal,
    978976                        "No alloc id for testbed %s !?" % tb)
     
    10211019                    # Create and start a thread to stop the segment
    10221020                    tp.wait_for_slot()
    1023                     uri = tbparams[tb]['uri']
     1021                    uri = tbparams[tb].uri
    10241022                    t  = pooled_thread(\
    10251023                            target=self.terminate_segment(log=log,
     
    10291027                                trusted_certs=self.trusted_certs,
    10301028                                caller=self.call_TerminateSegment),
    1031                             args=(uri, tbparams[tb]['federant']['allocID']),
     1029                            args=(uri, tbparams[tb].allocID),
    10321030                            name=tb,
    10331031                            pdata=tp, trace_file=self.trace_file)
     
    10401038                for tb in tbparams.keys():
    10411039                    try:
    1042                         self.release_access(tb, tbparams[tb]['allocID'],
    1043                                 tbmap=tbmap, uri=tbparams[tb].get('uri', None),
     1040                        self.release_access(tb, tbparams[tb].allocID,
     1041                                tbmap=tbmap, uri=tbparams[tb].uri,
    10441042                                cert_file=cert, cert_pwd=pw)
    10451043                    except service_error, e:
     
    13861384                        "Bad access response (no access proof)")
    13871385       
    1388         tbparam[tb] = {
    1389                 "allocID" : r['allocID'],
    1390                 "uri": uri,
    1391                 "proof": [ r['proof'] ],
    1392                 }
     1386        tbparam[tb] = allocation_info(allocID=r['allocID'].get('fedid', None),
     1387                tb=tb, uri=uri, proof=[r['proof']])
    13931388
    13941389        # Collect the responses corresponding to the services this testbed
     
    14051400        for a in r.get('fedAttr', []):
    14061401            try:
    1407                 if a['attribute'] and \
    1408                         isinstance(a['attribute'], basestring)\
    1409                         and not tbparam[tb].has_key(a['attribute'].lower()):
    1410                     tbparam[tb][a['attribute'].lower()] = a['value']
     1402                if a['attribute']:
     1403                    tbparam[tb].set_attribute(a['attribute'], a['value'])
    14111404            except KeyError:
    14121405                self.log.error("Bad attribute in response: %s" % a)
     
    15251518            # the loop.
    15261519            auth_attrs.update([
    1527                 (tbparams[tb]['allocID']['fedid'], "/%s/%s" % ( path, dest)) \
     1520                (tbparams[tb].allocID, "/%s/%s" % ( path, dest)) \
    15281521                        for tb in tbparams.keys()])
    15291522
     
    18291822        # allocation principal.  Yeah, that's a long list comprehension.
    18301823        self.append_experiment_authorization(expid, set([
    1831             (tbparams[tb]['allocID']['fedid'], "%s/%s" % (configpath, f)) \
     1824            (tbparams[tb].allocID, "%s/%s" % (configpath, f)) \
    18321825                    for tb in tbparams.keys() \
    18331826                        for f in ("hosts", 'ca.pem', 'node.pem',
     
    19821975        # save federant information
    19831976        for k in allocated.keys():
    1984             exp.add_allocation(
    1985                     allocation_info(
    1986                         tb=k,
    1987                         allocID=tbparams[k]['allocID'].get('fedid', None),
    1988                         uri=tbparams[k]['uri'],
    1989                         proof=tbparams[k]['proof'])
    1990                     )
     1977            exp.add_allocation(tbparams[k])
    19911978
    19921979        # Access proofs for the response message
    19931980        proofs = [copy.deepcopy(p) for k in tbparams.keys()\
    1994                     for p in tbparams[k]['proof']]
     1981                    for p in tbparams[k].proof]
    19951982        if self.state_filename:
    19961983            self.write_state()
     
    21052092                if store_keys:
    21062093                    auth_attrs.update(set([
    2107                         (tbparams[tb]['allocID']['fedid'], sk) \
     2094                        (tbparams[tb].allocID, sk) \
    21082095                                for sk in store_keys.split(" ")]))
    21092096
Note: See TracChangeset for help on using the changeset viewer.