Changeset 9a52a80


Ignore:
Timestamp:
Feb 1, 2013 1:25:11 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
master
Children:
328e93f
Parents:
5bd8f1b
Message:

Static routing

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fedd/deter/__init__.py

    r5bd8f1b r9a52a80  
    55from ip_allocator import *
    66from ip_addr import *
     7from topdl_to_route import *
  • fedd/federation/emulab_access.py

    r5bd8f1b r9a52a80  
    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

    r5bd8f1b r9a52a80  
    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)
  • fedkit/Makefile

    r5bd8f1b r9a52a80  
    33         config_from_tunnelip.pl active_config.pl combo.pl \
    44         prep_gateway.pl port_forward.pl setup_bridge.pl import_key.pl \
    5          gated_routing.pl start_seer.pl ospf_routing.pl quagga_routing.pl
     5         gated_routing.pl start_seer.pl ospf_routing.pl quagga_routing.pl \
     6         static_routing.pl
    67
    78LIBRARIES=gateway_lib.pm
  • fedkit/federate.pl

    r5bd8f1b r9a52a80  
    8888
    8989    foreach my $fn ("seer.conf", "client.conf", "userconf", "hosts",
    90             "ca.pem", "node.pem") {
     90            "ca.pem", "node.pem", "route.tgz") {
    9191        copy("$shared_config_dir/$fn", $local_config_dir )
    9292            if -e "$shared_config_dir/$fn";
    9393    }
     94    # If there are static routes, unpack them
     95    system("tar -C $local_config_dir -xzf $local_config_dir/route.tgz")
     96        if -e "$local_config_dir/route.tgz";
    9497
    9598    # Copy seer authorization files into the location that standard SEER
     
    169172
    170173if ($uname =~ /Linux/ ) {
    171     system("$perl /usr/local/federation/bin/gated_routing.pl")
    172         if -r "/usr/local/federation/bin/gated_routing.pl";
     174    system("$perl /usr/local/federation/bin/static_routing.pl")
     175        if -r "/usr/local/federation/bin/static_routing.pl";
     176    if ($?) {
     177        system("$perl /usr/local/federation/bin/gated_routing.pl")
     178            if -r "/usr/local/federation/bin/gated_routing.pl";
     179        }
    173180    if ($?) {
    174181        system("$perl /usr/local/federation/bin/quagga_routing.pl")
     
    177184}
    178185elsif ($uname =~/FreeBSD/ ) {
    179     # FreeBSD needs to have ospfs installed and a router config created and
    180     # run.
    181     system("$perl /usr/local/federation/bin/ospf_routing.pl")
    182         if -r "/usr/local/federation/bin/ospf_routing.pl";
     186    system("$perl /usr/local/federation/bin/static_routing.pl")
     187        if -r "/usr/local/federation/bin/static_routing.pl";
     188    if ($?) {
     189        # FreeBSD needs to have ospfs installed and a router config created and
     190        # run.
     191        system("$perl /usr/local/federation/bin/ospf_routing.pl")
     192            if -r "/usr/local/federation/bin/ospf_routing.pl";
     193    }
    183194}
    184195
Note: See TracChangeset for help on using the changeset viewer.