Changeset ab3d6c5


Ignore:
Timestamp:
Nov 29, 2011 3:53:09 PM (13 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
57facae
Parents:
ec3aa4d
Message:

Services into testbed nodes in topology

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    rec3aa4d rab3d6c5  
    3636from authorizer import abac_authorizer
    3737from thread_pool import thread_pool, pooled_thread
    38 from experiment_info import experiment_info, allocation_info
     38from experiment_info import experiment_info, allocation_info, federated_service
    3939
    4040import topdl
     
    4949fl = logging.getLogger("fedd.experiment_control")
    5050fl.addHandler(nullHandler())
    51 
    52 
    53 # Right now, no support for composition.
    54 class federated_service:
    55     def __init__(self, name, exporter=None, importers=None, params=None,
    56             reqs=None, portal=None):
    57         self.name=name
    58         self.exporter=exporter
    59         if importers is None: self.importers = []
    60         else: self.importers=importers
    61         if params is None: self.params = { }
    62         else: self.params = params
    63         if reqs is None: self.reqs = []
    64         else: self.reqs = reqs
    65 
    66         if portal is not None:
    67             self.portal = portal
    68         else:
    69             self.portal = (name in federated_service.needs_portal)
    70 
    71     def __str__(self):
    72         return "name %s export %s import %s params %s reqs %s" % \
    73                 (self.name, self.exporter, self.importers, self.params,
    74                         [ (r['name'], r['visibility']) for r in self.reqs] )
    75 
    76     needs_portal = ('SMB', 'seer', 'tmcd', 'project_export', 'seer_master')
    7751
    7852class experiment_control_local(experiment_control_legacy):
     
    14241398            raise service_error(service_error.protocol,
    14251399                        "Bad access response (no access proof)")
    1426        
     1400
    14271401        tbparam[tb] = allocation_info(allocID=r['allocID'].get('fedid', None),
    1428                 tb=tb, uri=uri, proof=[r['proof']])
     1402                tb=tb, uri=uri, proof=[r['proof']],
     1403                services=masters.get(tb, None))
    14291404
    14301405        # Collect the responses corresponding to the services this testbed
     
    14341409        for s in r.get('service', []):
    14351410            id = s.get('id', None)
     1411            # Note that this attaches the response to the object in the masters
     1412            # data structure.  (The e_keys index disappears when this fcn
     1413            # returns)
    14361414            if id and id in e_keys:
    14371415                e_keys[id].reqs.append(s)
     
    17671745    def get_testbed_services(self, req, testbeds):
    17681746        """
    1769         Parse the services section of the request into into two dicts mapping
    1770         testbed to lists of federated_service objects.  The first lists all
    1771         exporters of services, and the second all exporters of services that
    1772         need control portals in the experiment.
     1747        Parse the services section of the request into a dict mapping
     1748        testbed to lists of federated_service objects.  The dict maps all
     1749        exporters of services to those service objects.
    17731750        """
    17741751        masters = { }
    1775         pmasters = { }
    17761752        for s in req.get('service', []):
    17771753            # If this is a service request with the importall field
     
    18001776                    if tb in masters: masters[tb].append(fser)
    18011777                    else: masters[tb] = [fser]
    1802 
    1803                     if fser.portal:
    1804                         if tb not in pmasters: pmasters[tb] = [ fser ]
    1805                         else: pmasters[tb].append(fser)
    18061778                else:
    18071779                    self.log.error('Testbed service does not have name " + \
    18081780                            "and importers')
    1809         return masters, pmasters
     1781        return masters
    18101782
    18111783    def generate_keys_and_hosts(self, tmpdir, expid, hosts, tbparams):
     
    20151987            exp.add_allocation(tbparams[k])
    20161988            top.elements.append(topdl.Testbed(uri=tbparams[k].uri,
    2017                 type="testbed", localname=[k]))
     1989                type="testbed", localname=[k],
     1990                service=[ s.to_topdl() for s in tbparams[k].services]))
    20181991
    20191992        # Access proofs for the response message
     
    21062079                        testbeds.append(tb)
    21072080
    2108             masters, pmasters = self.get_testbed_services(req, testbeds)
     2081            masters = self.get_testbed_services(req, testbeds)
     2082            # The exporters who need portals
     2083            pmasters = dict([(k, [s for s in l if s.portal] ) \
     2084                    for k, l in masters.items()])
    21092085            allocated = { }         # Testbeds we can access
    21102086            topo ={ }               # Sub topologies
  • fedd/federation/experiment_info.py

    rec3aa4d rab3d6c5  
    22
    33import copy
     4import topdl
    45from datetime import datetime, timedelta
    56from numbers import Number
     7
     8class federated_service:
     9    def __init__(self, name, exporter=None, importers=None, params=None,
     10            reqs=None, portal=None):
     11        self.name=name
     12        self.exporter=exporter
     13        if importers is None: self.importers = []
     14        else: self.importers=importers
     15        if params is None: self.params = { }
     16        else: self.params = params
     17        if reqs is None: self.reqs = []
     18        else: self.reqs = reqs
     19
     20        if portal is not None:
     21            self.portal = portal
     22        else:
     23            self.portal = (name in federated_service.needs_portal)
     24
     25    def to_topdl(self):
     26        return topdl.Service(name=self.name, importer=self.importers)
     27
     28    def __str__(self):
     29        return "name %s export %s import %s params %s reqs %s" % \
     30                (self.name, self.exporter, self.importers, self.params,
     31                        [ (r['name'], r['visibility']) for r in self.reqs] )
     32
     33    needs_portal = ('SMB', 'seer', 'tmcd', 'project_export', 'seer_master')
    634
    735class allocation_info:
     
    1139    contact it.  In addition, the proofs of access are included.
    1240    """
    13     def __init__(self, allocID, tb, uri, proof=None):
     41    def __init__(self, allocID, tb, uri, proof=None, services=None):
    1442        self.allocID = allocID
    1543        self.tb = tb
    1644        self.uri = uri
    1745        self.proof = proof
     46        if services is not None: self.services = services
     47        else: self.services = [ ]
    1848        self.attrs = { }
    1949
Note: See TracChangeset for help on using the changeset viewer.