- Timestamp:
- Nov 29, 2011 3:53:09 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- 57facae
- Parents:
- ec3aa4d
- Location:
- fedd/federation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
rec3aa4d rab3d6c5 36 36 from authorizer import abac_authorizer 37 37 from thread_pool import thread_pool, pooled_thread 38 from experiment_info import experiment_info, allocation_info 38 from experiment_info import experiment_info, allocation_info, federated_service 39 39 40 40 import topdl … … 49 49 fl = logging.getLogger("fedd.experiment_control") 50 50 fl.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=name58 self.exporter=exporter59 if importers is None: self.importers = []60 else: self.importers=importers61 if params is None: self.params = { }62 else: self.params = params63 if reqs is None: self.reqs = []64 else: self.reqs = reqs65 66 if portal is not None:67 self.portal = portal68 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')77 51 78 52 class experiment_control_local(experiment_control_legacy): … … 1424 1398 raise service_error(service_error.protocol, 1425 1399 "Bad access response (no access proof)") 1426 1400 1427 1401 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)) 1429 1404 1430 1405 # Collect the responses corresponding to the services this testbed … … 1434 1409 for s in r.get('service', []): 1435 1410 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) 1436 1414 if id and id in e_keys: 1437 1415 e_keys[id].reqs.append(s) … … 1767 1745 def get_testbed_services(self, req, testbeds): 1768 1746 """ 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. 1773 1750 """ 1774 1751 masters = { } 1775 pmasters = { }1776 1752 for s in req.get('service', []): 1777 1753 # If this is a service request with the importall field … … 1800 1776 if tb in masters: masters[tb].append(fser) 1801 1777 else: masters[tb] = [fser] 1802 1803 if fser.portal:1804 if tb not in pmasters: pmasters[tb] = [ fser ]1805 else: pmasters[tb].append(fser)1806 1778 else: 1807 1779 self.log.error('Testbed service does not have name " + \ 1808 1780 "and importers') 1809 return masters , pmasters1781 return masters 1810 1782 1811 1783 def generate_keys_and_hosts(self, tmpdir, expid, hosts, tbparams): … … 2015 1987 exp.add_allocation(tbparams[k]) 2016 1988 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])) 2018 1991 2019 1992 # Access proofs for the response message … … 2106 2079 testbeds.append(tb) 2107 2080 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()]) 2109 2085 allocated = { } # Testbeds we can access 2110 2086 topo ={ } # Sub topologies -
fedd/federation/experiment_info.py
rec3aa4d rab3d6c5 2 2 3 3 import copy 4 import topdl 4 5 from datetime import datetime, timedelta 5 6 from numbers import Number 7 8 class 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') 6 34 7 35 class allocation_info: … … 11 39 contact it. In addition, the proofs of access are included. 12 40 """ 13 def __init__(self, allocID, tb, uri, proof=None ):41 def __init__(self, allocID, tb, uri, proof=None, services=None): 14 42 self.allocID = allocID 15 43 self.tb = tb 16 44 self.uri = uri 17 45 self.proof = proof 46 if services is not None: self.services = services 47 else: self.services = [ ] 18 48 self.attrs = { } 19 49
Note: See TracChangeset
for help on using the changeset viewer.