Changeset ab847bc
- Timestamp:
- Apr 28, 2010 4:09:53 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 12658df
- Parents:
- 05fceef
- Location:
- fedd/federation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/dragon_access.py
r05fceef rab847bc 9 9 import time 10 10 11 from threading import *11 from threading import Thread, Lock 12 12 from subprocess import Popen, call, PIPE, STDOUT 13 13 … … 804 804 # redoing the allocation. 805 805 self.state_lock.acquire() 806 retval = self. allocation[aid].get('started', None)806 retval = self.state[aid].get('started', None) 807 807 self.state_lock.release() 808 808 if retval: … … 858 858 self.export_store_info(certfile, vlan_no, connInfo) 859 859 860 860 861 if gri: 862 rtopo = topo.clone() 863 for s in rtopo.substrates: 864 s.set_attribute('vlan', vlan_no) 865 s.set_attribute('gri', gri) 866 861 867 # Grab the log (this is some anal locking, but better safe than 862 868 # sorry) … … 867 873 # if the 'started' key is in the allocation, we'll return it rather 868 874 # than redo the setup. 869 self. allocation[aid]['started'] = {875 self.state[aid]['started'] = { 870 876 'allocID': req['allocID'], 871 877 'allocationLog': logv, 878 'segmentdescription': { 879 'topdldescription': rtopo.to_dict() 880 }, 872 881 } 873 retval = self. allocation[aid]['started']882 retval = self.state[aid]['started'] 874 883 self.write_state() 875 884 self.state_lock.release() -
fedd/federation/emulab_access.py
r05fceef rab847bc 4 4 import stat # for chmod constants 5 5 import re 6 import random 6 7 import string 7 8 import copy … … 1458 1459 copy_file(f, "%s/%s" % (softdir, base)) 1459 1460 1461 ename = None 1462 pubkey_base = None 1463 secretkey_base = None 1460 1464 for a in attrs: 1461 1465 if a['attribute'] in configs: … … 1474 1478 if a['attribute'] == 'experiment_name': 1475 1479 ename = a['value'] 1480 1481 if not ename: 1482 ename = "" 1483 for i in range(0,5): 1484 ename += random.choice(string.ascii_letters) 1485 self.log.warn("No experiment name: picked one randomly: %s" \ 1486 % ename) 1487 1488 if not pubkey_base: 1489 raise service_error(service_error.req, 1490 "No public key attribute") 1491 1492 if not secretkey_base: 1493 raise service_error(service_error.req, 1494 "No secret key attribute") 1476 1495 1477 1496 # If the userconf service was imported, collect the configuration -
fedd/federation/experiment_control.py
r05fceef rab847bc 816 816 "More than one project export is not supported") 817 817 818 uri = self.tbmap.get(t b, None)818 uri = self.tbmap.get(testbed_base(tb), None) 819 819 if not uri: 820 820 raise service_error(service_error.server_config, … … 1120 1120 # Create and start a thread to start the segment, and save it 1121 1121 # to get the return value later 1122 tb_attrs = copy.copy(attrs) 1122 1123 thread_pool.wait_for_slot() 1123 uri = tbparams[tb].get('uri', self.tbmap.get(tb, None)) 1124 uri = tbparams[tb].get('uri', \ 1125 self.tbmap.get(testbed_base(tb), None)) 1126 base, suffix = split_testbed(tb) 1127 if suffix: 1128 tb_attrs.append({'attribute': 'experiment_name', 1129 'value': "%s_%s" % (eid, suffix)}) 1130 else: 1131 tb_attrs.append({'attribute': 'experiment_name', 'value': eid}) 1124 1132 if not uri: 1125 1133 raise service_error(service_error.internal, … … 1141 1149 t = self.pooled_thread(\ 1142 1150 target=s, name=tb, 1143 args=(uri, aid, topo[tb], masters, attrs, connInfo[tb]),1151 args=(uri, aid, topo[tb], masters, tb_attrs, connInfo[tb]), 1144 1152 pdata=thread_pool, trace_file=self.trace_file) 1145 1153 threads.append(t) … … 1723 1731 try: 1724 1732 os.makedirs(configdir) 1725 except IOError, e:1726 raise service_error( 1733 except EnvironmentError, e: 1734 raise service_error(service_error.internal, 1727 1735 "Cannot create config directory: %s" % e) 1728 1736 try: … … 1752 1760 part.add_portals(top, topo, eid, masters, tbparams, ip_allocator, 1753 1761 connInfo, expid) 1754 # Now get access to the dynamic testbeds 1755 for k, t in topo.items(): 1756 if not t.get_attribute('dynamic'): 1757 continue 1758 tb = t.get_attribute('testbed') 1759 if tb: 1760 self.get_access(tb, None, tbparams, export_project, 1761 access_user, masters) 1762 tbparams[k] = tbparams[tb] 1763 del tbparams[tb] 1764 allocated[k] = 1 1765 store_keys = t.get_attribute('store_keys') 1766 # Give the testbed access to keys it exports or imports 1767 if store_keys: 1768 for sk in store_keys.split(" "): 1769 self.auth.set_attribute(\ 1770 tbparams[k]['allocID']['fedid'], sk) 1771 else: 1772 raise service_error(service_error.internal, 1773 "Dynamic allocation from no testbed!?") 1762 # Now get access to the dynamic testbeds (those added above) 1763 for tb in [ t for t in topo if t not in allocated]: 1764 self.get_access(tb, None, tbparams, access_user, masters) 1765 allocated[tb] = 1 1766 store_keys = topo[tb].get_attribute('store_keys') 1767 # Give the testbed access to keys it exports or imports 1768 if store_keys: 1769 for sk in store_keys.split(" "): 1770 self.auth.set_attribute(\ 1771 tbparams[tb]['allocID']['fedid'], sk) 1774 1772 1775 1773 self.wrangle_software(expid, top, topo, tbparams) … … 1848 1846 (self.repo_url, expid) 1849 1847 }, 1850 {1851 'attribute': 'experiment_name',1852 'value': eid,1853 },1854 1848 ] 1855 1849 -
fedd/federation/experiment_partition.py
r05fceef rab847bc 212 212 "Cannot DRAGON split substrate w/o capacity") 213 213 segs = [ ] 214 substr = topdl.Substrate(name="dragon%d" % idx, 214 name = join_testbed("dragon", "%d" % idx) 215 substr = topdl.Substrate(name=name, 215 216 capacity=sub.capacity.clone(), 216 217 attribute=[ topdl.Attribute(attribute=n, value=v) 217 218 for n, v, in (\ 218 219 ('vlan', 'unassigned%d' % idx),)]) 219 name = "dragon%d" % idx220 220 store_key = 'fedid:%s/vlan%d' % (expid, idx) 221 221 for tb in tbs.keys(): … … 574 574 id= tbparams[mtb]['allocID'], 575 575 type='emulab', 576 uri = self.tbmap.get( master, None),576 uri = self.tbmap.get(testbed_base(mtb), None), 577 577 interface=[ 578 578 topdl.Interface( … … 603 603 id= tbparams[tb]['allocID'], 604 604 type='emulab', 605 uri = self.tbmap.get(t b, None),605 uri = self.tbmap.get(testbed_base(tb), None), 606 606 interface=[ 607 607 topdl.Interface( … … 625 625 topo[mtb].elements.append(portal) 626 626 topo[mtb].elements.append(seg) 627 for t in (m aster, tb):627 for t in (mtb, tb): 628 628 topo[t].incorporate_elements() 629 629 -
fedd/federation/util.py
r05fceef rab847bc 213 213 raise failed_excpetion 214 214 215 # Functions to manipulate composite testbed names 216 def testbed_base(tb): 217 """ 218 Simple code to get the base testebd name. 219 """ 220 i = tb.find('/') 221 if i == -1: return tb 222 else: return tb[0:i] 223 224 def testbed_suffix(tb): 225 """ 226 Simple code to get a testbed suffix, if nay. No suffix returns None. 227 """ 228 i = tb.find('/') 229 if i != -1: return tb[i+1:] 230 else: return None 231 232 def split_testbed(tb): 233 """ 234 Return a testbed and a suffix as a tuple. No suffix returns None for that 235 field 236 """ 237 238 i = tb.find('/') 239 if i != -1: return (tb[0:i], tb[i+1:]) 240 else: return (tb, None) 241 242 def join_testbed(base, suffix=None): 243 """ 244 Build a testbed with suffix. If base is itself a tuple, combine them, 245 otherwise combine the two. 246 """ 247 if isinstance(base, tuple): 248 if len(base) == 2: 249 return '/'.join(base) 250 else: 251 raise RuntimeError("Too many tuple elements for join_testbed") 252 else: 253 if suffix: 254 return '/'.join((base, suffix)) 255 else: 256 return base
Note: See TracChangeset
for help on using the changeset viewer.