Changeset 63f7c7e for fedkit/splitter.pl


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.