Changeset 63f7c7e


Ignore:
Timestamp:
Sep 4, 2007 6:52:58 PM (17 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
c23025e
Parents:
61f19e0
Message:

add hosts fixup

Location:
fedkit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedkit/federate.sh

    r61f19e0 r63f7c7e  
    33BOSSNODE="/usr/local/etc/emulab/bossnode"
    44# GATEWAY="detertunnel"
     5
     6PORTS="139 7777"
     7NC="/usr/bin/nc"
     8RCDIR="/usr/local/etc/emulab/rc"
     9
     10RCACCT="rc.accounts"
     11SMBMOUNT="smbmount.pl"
    512
    613if [ -f $BOSSNODE ]
     
    1017
    1118EMUDIR="/usr/local/etc/emulab/"
     19
     20# Find this experiment's stashed scripts.  (Perl for advanced parsing)
     21SCRIPTDIR=`$EMUDIR/tmcc -b status | perl -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "/proj/$1/exp/$2/tmp\n";'`
     22
     23# Die if things are weird
     24if [ -z "$SCRIPTDIR" ] ; then
     25    echo "Can't find federation scripts.  Tmcc status says:"
     26    $EMUDIR/tmcc -b status
     27    exit 1;
     28fi
     29
     30# Move the SMB mounting script out of NFS so we can call it after the umount
     31cp "$SCRIPTDIR/$SMBMOUNT" /tmp
     32
     33# Copy the global hostnames file into /etc/hosts so this node can address
     34# others in the experiment on other testbeds.
     35grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts
     36cat "$SCRIPTDIR/hosts" >> /tmp/hosts
     37cp /tmp/hosts /etc/hosts && rm /tmp/hosts
     38
    1239GATEWAY=`$EMUDIR/tmcc -b syncserver | awk ' { match($0, /SERVER=[^[:space:]]+/); print substr($0,RSTART+8,RLENGTH-9);}'`
    13 
    14 PORTS="139 7777"
    15 NC="/usr/bin/nc"
    16 RCDIR="/usr/local/etc/emulab/rc"
    17 
    18 RCACCT="rc.accounts"
    19 SMBMOUNT="smbmount.pl"
    2040
    2141#
     
    4363echo $GATEWAY > $BOSSNODE
    4464
     65
    4566#
    4667# Unmount stuff before messing with accounts
     
    6081echo "Mounting via SMB."
    6182
    62 exec $EMUDIR/$SMBMOUNT
     83exec "/tmp/$SMBMOUNT"
  • fedkit/splitter.pl

    r61f19e0 r63f7c7e  
    22
    33use Getopt::Std;
     4
     5@scripts = ("federate.sh", "smbmount.pl");
     6$local_script_dir = ".";
    47
    58# use scp to transfer a file, reporting true if successful and false otherwise.
     
    4144    }
    4245    else { return 1; }
     46}
     47
     48# Ship local copies of the federation scripts out to the given host.  If any of
     49# the script transfers fails, return 0.  The scripts to transfer are from the
     50# global @scripts and are found locally in $local_script_dir (another global).
     51sub ship_scripts {
     52    my($host, $user, $dest_dir) = @_;       # Where, who, where remotely
     53    my($s);
     54
     55    for $s (@scripts) {
     56        &scp_file("$local_script_dir/$s", "$user\@$host", $dest_dir) ||
     57            return 0;
     58    }
     59    return 1;
    4360}
    4461
     
    6077    my($tclfile) = "./$eid.$tb.tcl";        # Local tcl file with the
    6178                                            # sub-experiment
    62     my($to_hostname) = "/proj/$pid/hosts.$eid"; # remote hostnames file
     79    my($proj_dir) = "/proj/$pid/exp/$eid/tmp";  # Where to stash federation stuff
     80    my($to_hostname) = "$proj_dir/hosts";   # remote hostnames file
    6381
    6482    # Determine the status of the remote experiment
     
    7997    print "$tb: $state\n";
    8098
    81     # Copy the configuration data over (unless the host is local)
     99    # Copy the experiment definition data over (unless the host is local)
    82100    if ( $host ne "localhost") {
    83101        &scp_file($tclfile, "$user\@$host") || return 0;
    84         &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
    85102    }
    86103
    87104    # Remote experiment is active.  Modify it.
    88105    if ($state eq "active") {
     106        # First copy new scripts and hostinfo into the remote /proj
     107        &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
     108        &ship_scripts($host, $user, $proj_dir) || return 0;
    89109        &ssh_cmd($user, $host, "/usr/testbed/bin/modexp -r -s -w $pid " .
    90110            "$eid $tclfile", "modexp") || return 0;
     
    96116        &ssh_cmd($user, $host, "/usr/testbed/bin/modexp -w $pid $eid $tclfile",
    97117            "modexp") || return 0;
     118        # First copy new scripts and hostinfo into the remote /proj
     119        &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
     120        &ship_scripts($host, $user, $proj_dir) || return 0;
     121        # Now start up
    98122        &ssh_cmd($user, $host, "/usr/testbed/bin/swapexp -w $pid $eid in",
    99123            "swapexp") || return 0;
     
    101125    }
    102126
    103     # No remote experiment.  Create one.
     127    # No remote experiment.  Create one.  We do this in 2 steps so we can put
     128    # the configuration files and scripts into the new experiment directories.
    104129    if ($state eq "none") {
    105         &ssh_cmd($user, $host, "/usr/testbed/bin/startexp -i -w -p " .
     130        &ssh_cmd($user, $host, "/usr/testbed/bin/startexp -f -w -p " .
    106131            "$pid -e $eid $tclfile", "startexp") || return 0;
     132        # First copy new scripts and hostinfo into the remote /proj
     133        &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
     134        &ship_scripts($host, $user, $proj_dir) || return 0;
     135        # Now start up
     136        &ssh_cmd($user, $host, "/usr/testbed/bin/swapexp -w $pid $eid in",
     137            "swapexp") || return 0;
    107138        return 1;
    108139    }
     
    138169
    139170# Argument processing.
    140 getopts('c:m:e:f:n', \%opts);
     171getopts('d:c:m:e:f:n', \%opts);
    141172
    142173$eid = $opts{'e'};                  # Experiment ID
     
    145176$startem = $opts{'n'} ? 0 : 1;      # If true, start the sub-experiments
    146177$config = $opts{'c'} || "./testbeds";
     178$local_script_dir = $opts{'d'};     # Local scripts
     179
     180for $s (@scripts) {
     181    die "$local_script_dir/$s not in local script directory. Try -d\n"
     182        unless -r "$local_script_dir/$s";
     183}
    147184
    148185die "Must supply file, master and experiment" unless $master && $tcl && $eid;
     
    265302
    266303B<splitter.pl> B<-e> I<experiment> B<-m> I<master_testbed> [B<-n>]
    267     [B<-c> I<config_file>] [B<-f> I<experiment_tcl>] [I<experiment_tcl>]
     304    [B<-d> F<script_dir>] [B<-c> F<config_file>] [B<-f> F<experiment_tcl>]
     305    [F<experiment_tcl>]
    268306
    269307=head1 DESCRIPTION
     
    289327currently instantiated last.
    290328
     329Scripts to start federation are copied into the local experiment's tmp file -
     330e.g., F</proj/DETER/exp/simple-split/tmp>.  These are taken from the directory
     331given by the B<-d> option.
     332
    291333If any sub-experiment fails to instantiate, the other sub-exeriments are
    292334swapped out.
Note: See TracChangeset for help on using the changeset viewer.