Changeset ab847bc


Ignore:
Timestamp:
Apr 28, 2010 4:09:53 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
12658df
Parents:
05fceef
Message:

New syntax for testbeds that includes a /instance rider. This allows users to
request multiple segments from a single testbed.

Location:
fedd/federation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/dragon_access.py

    r05fceef rab847bc  
    99import time
    1010
    11 from threading import *
     11from threading import Thread, Lock
    1212from subprocess import Popen, call, PIPE, STDOUT
    1313
     
    804804            # redoing the allocation.
    805805            self.state_lock.acquire()
    806             retval = self.allocation[aid].get('started', None)
     806            retval = self.state[aid].get('started', None)
    807807            self.state_lock.release()
    808808            if retval:
     
    858858        self.export_store_info(certfile, vlan_no, connInfo)
    859859
     860
    860861        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
    861867            # Grab the log (this is some anal locking, but better safe than
    862868            # sorry)
     
    867873            # if the 'started' key is in the allocation, we'll return it rather
    868874            # than redo the setup.
    869             self.allocation[aid]['started'] = {
     875            self.state[aid]['started'] = {
    870876                    'allocID': req['allocID'],
    871877                    'allocationLog': logv,
     878                    'segmentdescription': {
     879                        'topdldescription': rtopo.to_dict()
     880                        },
    872881                    }
    873             retval = self.allocation[aid]['started']
     882            retval = self.state[aid]['started']
    874883            self.write_state()
    875884            self.state_lock.release()
  • fedd/federation/emulab_access.py

    r05fceef rab847bc  
    44import stat # for chmod constants
    55import re
     6import random
    67import string
    78import copy
     
    14581459                    copy_file(f, "%s/%s" % (softdir, base))
    14591460
     1461            ename = None
     1462            pubkey_base = None
     1463            secretkey_base = None
    14601464            for a in attrs:
    14611465                if a['attribute'] in configs:
     
    14741478                if a['attribute'] == 'experiment_name':
    14751479                    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")
    14761495
    14771496            # If the userconf service was imported, collect the configuration
  • fedd/federation/experiment_control.py

    r05fceef rab847bc  
    816816                        "More than one project export is not supported")
    817817
    818         uri = self.tbmap.get(tb, None)
     818        uri = self.tbmap.get(testbed_base(tb), None)
    819819        if not uri:
    820820            raise service_error(service_error.server_config,
     
    11201120            # Create and start a thread to start the segment, and save it
    11211121            # to get the return value later
     1122            tb_attrs = copy.copy(attrs)
    11221123            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})
    11241132            if not uri:
    11251133                raise service_error(service_error.internal,
     
    11411149            t  = self.pooled_thread(\
    11421150                    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]),
    11441152                    pdata=thread_pool, trace_file=self.trace_file)
    11451153            threads.append(t)
     
    17231731            try:
    17241732                os.makedirs(configdir)
    1725             except IOError, e:
    1726                 raise service_error(
     1733            except EnvironmentError, e:
     1734                raise service_error(service_error.internal,
    17271735                        "Cannot create config directory: %s" % e)
    17281736            try:
     
    17521760            part.add_portals(top, topo, eid, masters, tbparams, ip_allocator,
    17531761                    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)
    17741772
    17751773            self.wrangle_software(expid, top, topo, tbparams)
     
    18481846                            (self.repo_url, expid)
    18491847                },
    1850                 {
    1851                     'attribute': 'experiment_name',
    1852                     'value': eid,
    1853                 },
    18541848            ]
    18551849
  • fedd/federation/experiment_partition.py

    r05fceef rab847bc  
    212212                    "Cannot DRAGON split substrate w/o capacity")
    213213        segs = [ ]
    214         substr = topdl.Substrate(name="dragon%d" % idx,
     214        name = join_testbed("dragon", "%d" % idx)
     215        substr = topdl.Substrate(name=name,
    215216                capacity=sub.capacity.clone(),
    216217                attribute=[ topdl.Attribute(attribute=n, value=v)
    217218                    for n, v, in (\
    218219                            ('vlan', 'unassigned%d' % idx),)])
    219         name = "dragon%d" % idx
    220220        store_key = 'fedid:%s/vlan%d' % (expid, idx)
    221221        for tb in tbs.keys():
     
    574574                                id= tbparams[mtb]['allocID'],
    575575                                type='emulab',
    576                                 uri = self.tbmap.get(master, None),
     576                                uri = self.tbmap.get(testbed_base(mtb), None),
    577577                                interface=[
    578578                                    topdl.Interface(
     
    603603                                id= tbparams[tb]['allocID'],
    604604                                type='emulab',
    605                                 uri = self.tbmap.get(tb, None),
     605                                uri = self.tbmap.get(testbed_base(tb), None),
    606606                                interface=[
    607607                                    topdl.Interface(
     
    625625                        topo[mtb].elements.append(portal)
    626626                        topo[mtb].elements.append(seg)
    627                         for t in (master, tb):
     627                        for t in (mtb, tb):
    628628                            topo[t].incorporate_elements()
    629629
  • fedd/federation/util.py

    r05fceef rab847bc  
    213213        raise failed_excpetion
    214214
     215# Functions to manipulate composite testbed names
     216def 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
     224def 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
     232def 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
     242def 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.