Changeset 328e93f for fedd


Ignore:
Timestamp:
Feb 1, 2013 1:25:43 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
master
Children:
17c6d91
Parents:
9a52a80 (diff), 06a2b49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of tardis.deterlab.net:/var/local/git/fedd

Location:
fedd
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • fedd/deter/__init__.py

    r06a2b49 r328e93f  
    55from ip_allocator import *
    66from ip_addr import *
     7from topdl_to_route import *
  • fedd/federation/deter_impl.py

    r9a52a80 r328e93f  
    88import deter_internal_access
    99import benito_access
     10import desktop_access
    1011import skeleton_access
    1112
     
    8990                elif self.access_type == "benito":
    9091                    self.access = benito_access.access(config, self.auth)
     92                elif self.access_type == "desktop":
     93                    self.access = desktop_access.access(config, self.auth)
    9194                elif self.access_type == "skel":
    9295                    self.access = skeleton_access.access(config, self.auth)
  • fedd/federation/emulab_access.py

    r06a2b49 r328e93f  
    691691        """
    692692        configs = ('hosts', 'ssh_pubkey', 'ssh_secretkey',
    693                 'seer_ca_pem', 'seer_node_pem')
     693                'seer_ca_pem', 'seer_node_pem', 'route.tgz')
    694694        ename = None
    695695        pubkey_base = None
  • fedd/federation/experiment_control.py

    r06a2b49 r328e93f  
    4444from deter import ip_allocator
    4545from deter import ip_addr
     46from deter import topology_to_route_file
    4647import list_log
    4748
     
    137138                or 'legacy'
    138139        self.auth_dir = config.get('experiment_control', 'auth_dir')
     140        self.routing = config.get('experiment_control', 'routing')
    139141        # XXX: document this!
    140142        self.info_cache_limit = \
     
    12041206
    12051207        for p, a in attrs:
    1206             # PNNL Debug
    1207             self.log.debug("Append auth: %s %s" % (p, a))
    12081208            if p and a:
    12091209                # Improperly configured overrides can add bad principals.
     
    16231623        """
    16241624
    1625         # XXX: PNNL debug
    1626         self.log.debug("calling wrangle software")
    16271625        # Copy the rpms and tarfiles to a distribution directory from
    16281626        # which the federants can retrieve them
     
    16371635        pkgs.update([x.location for e in top.elements for x in e.software])
    16381636        try:
    1639             # XXX: PNNL debug
    1640             self.log.debug("wrangle software: makedirs")
    16411637            os.makedirs(softdir)
    1642             # XXX: PNNL debug
    1643             self.log.debug("wrangle software: makedirs success")
    16441638        except EnvironmentError, e:
    16451639            raise service_error(
     
    19611955        Create the ssh keys necessary for interconnecting the portal nodes and
    19621956        the global hosts file for letting each segment know about the IP
    1963         addresses in play.  Save these into the repo.  Add attributes to the
    1964         autorizer allowing access controllers to download them and return a set
    1965         of attributes that inform the segments where to find this stuff.  May
     1957        addresses in play.  If we have computed static routes, copy them into
     1958        the repo. Save these into the repo.  Add attributes to the autorizer
     1959        allowing access controllers to download them and return a set of
     1960        attributes that inform the segments where to find this stuff.  May
    19661961        raise service_errors in if there are problems.
    19671962        """
     
    19711966        gw_pubkey = os.path.join(keydir, gw_pubkey_base)
    19721967        gw_secretkey = os.path.join(keydir, gw_secretkey_base)
     1968        route = os.path.join(tmpdir, 'route.tgz')
    19731969
    19741970        try:
     
    19851981        # The config file system location
    19861982        configdir ="%s%s" % ( self.repodir, configpath)
     1983        route_conf = os.path.join(configdir, 'route.tgz')
    19871984        try:
    19881985            os.makedirs(configdir)
     
    19981995                    "Cannot write hosts file: %s" % e)
    19991996        try:
     1997            if os.path.exists(route):
     1998                copy_file(route, route_conf)
     1999
    20002000            copy_file(gw_pubkey, os.path.join(configdir, gw_pubkey_base))
    20012001            copy_file(gw_secretkey, os.path.join(configdir, gw_secretkey_base))
     
    20142014            (tbparams[tb].allocID, "%s/%s" % (configpath, f)) \
    20152015                    for tb in tbparams.keys() \
    2016                         for f in ("hosts", 'ca.pem', 'node.pem',
     2016                        for f in ("hosts", 'ca.pem', 'node.pem', 'route.tgz',
    20172017                            gw_secretkey_base, gw_pubkey_base)]))
    20182018
     
    20442044                },
    20452045            ]
     2046        # Add info about static routes if we have some
     2047        if os.path.exists(route_conf):
     2048            attrs.append(
     2049                {
     2050                    'attribute': 'route.tgz',
     2051                    'value': '%s/%s/config/%s' % \
     2052                            (self.repo_url, expid, 'route.tgz')
     2053                }
     2054            )
    20462055        return attrs
    20472056
     
    21702179                raise service_error(service_error.req, "No such experiment")
    21712180
     2181    @staticmethod
     2182    def needs_route_computation(req):
     2183        '''
     2184        Walk the request services looking for a static routing request
     2185        '''
     2186        for s in req.get('service', []):
     2187            if s.get('name', '') == 'static_routing':
     2188                return True
     2189        return False
     2190
     2191    def compute_static_routes(self, tmpdir, top):
     2192        '''
     2193        Compute a set of static routes for the topology.  The result is a file
     2194        called route.tgz in tmpdir that contains a dinrectory, route, with a
     2195        file per node in the topology that lists the prefix and router for all
     2196        the routes in that node's routing table.  Exceptions from the route
     2197        calculation program and the tar creation call are not caught.
     2198        '''
     2199        if self.routing is None:
     2200            raise service_error(service_error.server,
     2201                    'Cannot provide staticroutes, no routing program specified')
     2202        rg = tempfile.NamedTemporaryFile()
     2203        outdir = os.path.join(tmpdir, 'route')
     2204        tarfile = os.path.join(tmpdir, 'route.tgz')
     2205        topology_to_route_file(top, file=rg)
     2206        os.mkdir(outdir)
     2207        try:
     2208            for cmd in (
     2209                    [self.routing, '--input', rg.name,'--output', outdir],
     2210                    ['tar', '-C', tmpdir, '-czf', tarfile, 'route']):
     2211                subprocess.check_call(cmd)
     2212        except subprocess.CalledProcessError, e:
     2213            raise service_error(service_error.internal,
     2214                    'Cannot call %s: %s' % (' '.join(cmd), e.returncode))
     2215        rg.close()
     2216        shutil.rmtree(outdir)
     2217
     2218
    21722219   
    21732220    def save_federant_information(self, allocated, tbparams, eid, top):
     
    22792326            # Assign the IPs
    22802327            hosts, ip_allocator = self.allocate_ips_to_topo(top)
     2328            if self.needs_route_computation(req):
     2329                self.compute_static_routes(tmpdir, top)
    22812330            # Find the testbeds to look up
    22822331            tb_hosts = { }
     
    22842333            for e in top.elements:
    22852334                if isinstance(e, topdl.Computer):
    2286                     tb = e.get_attribute('testbed') or 'default'
     2335                    tb = e.get_attribute('testbed')
     2336                    # Put nodes not in a testbed into the 'default' testbed if
     2337                    # 'default' is in the fedd map, the instantiation will
     2338                    # work.
     2339                    if tb is None:
     2340                        tb = 'default'
     2341                        e.set_attribute('testbed', tb)
    22872342                    if tb in tb_hosts: tb_hosts[tb].append(e.name)
    22882343                    else:
     
    23062361
    23072362            attrs = self.generate_keys_and_hosts(tmpdir, expid, hosts, tbparams)
    2308             # XXX: PNNL debug
    2309             self.log.debug("Back from generate keys")
    23102363
    23112364            part = experiment_partition(self.auth, self.store_url, tbmap,
     
    23132366            part.add_portals(top, topo, eid, pmasters, tbparams, ip_allocator,
    23142367                    connInfo, expid)
    2315             # XXX: PNNL debug
    2316             self.log.debug("Back from add portals")
    23172368
    23182369            auth_attrs = set()
    23192370            # Now get access to the dynamic testbeds (those added above)
    23202371            for tb in [ t for t in topo if t not in allocated]:
    2321                 # XXX: PNNL debug
    2322                 self.log.debug("dynamic testbeds %s" %tb)
    23232372                self.get_access(tb, tbparams, fid, masters, tbmap,
    23242373                        expid, expcert_file)
     
    23312380                                for sk in store_keys.split(" ")]))
    23322381
    2333             # XXX: PNNL debug
    2334             self.log.debug("done with dynamic testbeds %s" % auth_attrs)
    23352382            if auth_attrs:
    23362383                self.append_experiment_authorization(expid, auth_attrs)
  • fedd/federation/util.py

    r06a2b49 r328e93f  
    218218    while not ok and retries < max_retries:
    219219        try:
    220             if log:
    221                 log.debug('Creating HTTPSConnection: %s' % cf)
    222220            conn = httplib.HTTPSConnection(po.hostname, port=po.port,
    223221                    cert_file=cf, key_file=cf, timeout=30)
    224222            conn.putrequest('GET', po.path)
    225223            conn.endheaders()
    226             if log:
    227                 log.debug('Connecting')
    228224            response = conn.getresponse()
    229             if log:
    230                 log.debug('Connected')
    231225
    232226            lf = open("%s/%s" % (destdir, fn), "w")
    233             if log:
    234                 log.debug('initial read')
    235227            buf = response.read(4096)
    236228            while buf:
    237229                lf.write(buf)
    238                 if log:
    239                     log.debug('loop read')
    240230                buf = response.read(4096)
    241231            lf.close()
Note: See TracChangeset for help on using the changeset viewer.