Changeset c23025e for fedkit


Ignore:
Timestamp:
Sep 11, 2007 5:51:25 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:
4addf9d
Parents:
63f7c7e
Message:

pre-testing commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/splitter.pl

    r63f7c7e rc23025e  
    3333
    3434    # XXX system with a relative pathname is sort of gross
    35     if ( $host ne "localhost") {
    36         system ("ssh $user\@$host $cmd");
    37     }
    38     else {
    39         system ("$cmd");
    40     }
     35    # if ( $host ne "localhost") {
     36        #system ("ssh $user\@$host $cmd");
     37        #}
     38    #else {
     39        #system ("$cmd");
     40        #}
     41    system ("ssh $user\@$host $cmd");
    4142    if ($?) {
    4243        warn "$wname failed $?\n" if $wname;
     
    6667# hash, as is the project name on the remote testbed.  Parameters are the
    6768# testbed and the experiment id.  Configuration files are scp-ed over to the
    68 # target testbed.  Then the current state of the experiment determined using
    69 # expinfo.  From that state, the experiment is either created, modified or
    70 # spapped in.  If everything succeeds, true is returned.
     69# target testbed from the global $tmpdir/$tb directory.  Then the current state
     70# of the experiment determined using expinfo.  From that state, the experiment
     71# is either created, modified or spapped in.  If everything succeeds, true is
     72# returned.
    7173sub start_segment {
    7274    my($tb, $eid) = @_;                     # testbed and experiment ID
    73     my($host) = $host{$tb};                 # Host name of remote users
     75    my($host) = "$host{$tb}$domain{$tb}";   # Host name of remote ops (FQDN)
    7476    my($user) = $user{$tb};                 # user to pass to ssh
    7577    my($pid) = $project{$tb};               # remote project to start the
     
    8183
    8284    # Determine the status of the remote experiment
    83     if ( $host ne "localhost") {
    84         open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") ||
    85             die "Can't ssh to $user\@$host:$!\n";
    86     }
    87     else {
    88         open(STATUS, "/usr/testbed/bin/expinfo $pid $eid|") ||
    89             die "Can't call expinfo locally";
    90     }
     85    #if ( $host ne "localhost") {
     86#       open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") ||
     87#           die "Can't ssh to $user\@$host:$!\n";
     88#    }
     89#    else {
     90#       open(STATUS, "/usr/testbed/bin/expinfo $pid $eid|") ||
     91#           die "Can't call expinfo locally";
     92#    }
     93    open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") ||
     94        die "Can't ssh to $user\@$host:$!\n";
    9195    # XXX: this is simple now.  Parsing may become more complex
    9296    while (<STATUS>) {
     
    98102
    99103    # Copy the experiment definition data over (unless the host is local)
    100     if ( $host ne "localhost") {
    101         &scp_file($tclfile, "$user\@$host") || return 0;
    102     }
    103 
     104    #if ( $host ne "localhost") {
     105#       &scp_file("$tmpdir/$tb/$tclfile", "$user\@$host") || return 0;
     106#    }
     107#    else {
     108#       # XXX this ain't quite right
     109#       system("cp $tmpdir/$tb/$tclfile .");
     110#    }
     111
     112    &scp_file("$tmpdir/$tb/$tclfile", "$user\@$host") || return 0;
    104113    # Remote experiment is active.  Modify it.
    105114    if ($state eq "active") {
    106115        # First copy new scripts and hostinfo into the remote /proj
    107         &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
     116        &scp_file("$tmpdir/$tb/hostnames", "$user\@$host", $to_hostname) ||
     117            return 0;
    108118        &ship_scripts($host, $user, $proj_dir) || return 0;
    109119        &ssh_cmd($user, $host, "/usr/testbed/bin/modexp -r -s -w $pid " .
     
    151161    my($tb, $eid) = @_;
    152162    my($user) = "$user{$tb}";
    153     my($host) = "$host{$tb}";
     163    my($host) = "$host{$tb}$domain{$tb}";
    154164    my($pid) = $project{$tb};
    155165
     
    159169}
    160170
    161 $tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl";         # tcl program to split experiments
     171# tcl program to split experiments
     172# $tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl";
     173$tcl_splitter = "/users/faber/testbed/tbsetup/ns2ir/parse.tcl";
    162174$tclsh = "/usr/local/bin/otclsh";   # tclsh to call directly
    163175
     
    169181
    170182# Argument processing.
    171 getopts('d:c:m:e:f:n', \%opts);
     183getopts('d:c:m:e:f:nt:', \%opts);
    172184
    173185$eid = $opts{'e'};                  # Experiment ID
     
    175187$master = $opts{'m'};               # Master testbed
    176188$startem = $opts{'n'} ? 0 : 1;      # If true, start the sub-experiments
     189$tmpdir = $opts{'t'} || "/tmp";             # where to collect tmp files
    177190$config = $opts{'c'} || "./testbeds";
    178191$local_script_dir = $opts{'d'};     # Local scripts
     192
     193$tmpdir .= "/split$$";
     194
     195unless (-d "$tmpdir") {
     196    mkdir("$tmpdir") || die "Can't create $tmpdir: $!";
     197}
     198
    179199
    180200for $s (@scripts) {
     
    190210    next if /^#/;
    191211    chomp;
    192     ($tb, $h, $u, $p, $es, $gs, $mes, $mgs, $t, $i) = split(":", $_);
     212    ($tb, $h, $d, $u, $p, $es, $gs, $mes, $mgs, $t, $i) = split(":", $_);
    193213    $host{$tb} = $h;
    194214    $user{$tb} = $u;
     215    $domain{$tb} = $d;
    195216    $project{$tb} = $p;
    196217    $gwtype{$tb} = $t;
     
    200221    $mgwstart{$tb} = $mgs;
    201222    $gwimage{$tb} = $i;
     223
     224    # Make sure the domain starts with a period
     225    $domain{$tb} = ".$domain{$tb}" unless $domain{$tb} =~ /^\./;
    202226}
    203227close(CONF);
    204228
    205229# Open a pipe to the splitter program and start it parsing the experiments
    206 open(PIPE, "$tclsh $tcl_splitter -s -p $pid $gid $eid $tcl|") ||
     230open(PIPE, "$tclsh $tcl_splitter -s -m $master -p $pid $gid $eid $tcl|") ||
    207231    die "Cannot execute $tclsh $tcl_splitter -s -p $pid $gid $eid $tcl:$!\n";
    208232
     
    218242        if ($host{$ctb}) {
    219243            $allocated{$ctb}++; # Keep track of the testbeds allocated
    220             $destfile = "./$eid.$ctb.tcl";
     244
     245            unless (-d "$tmpdir/$ctb") {
     246                mkdir("$tmpdir/$ctb") || die "Can't create $tmpdir/$ctb: $!";
     247            }
     248            $destfile = "$tmpdir/$ctb/$eid.$ctb.tcl";
    221249
    222250            open(FILE, ">$destfile") || die "Cannot open $destfile:$!\n";
     
    228256        next;
    229257    };
     258
    230259    # End of that experiment
    231260    /^#\s+End\s+Testbed\s+\((\w+)\)/ && do {
     
    236265        next;
    237266    };
     267
     268    # Beginning of a gateway set
     269    /^#\s+Begin\s+gateways\s+\((\w+)\)/ && do {
     270        $gateways = $1;
     271        # If we've heard of this tb, create the config lines for it one at a
     272        # time.
     273        if ($allocated{$gateways}) {
     274            # Just in case.  This directory should already have been created
     275            # above.
     276            unless (-d "$tmpdir/$gateways") {
     277                mkdir("$tmpdir/$gateways") ||
     278                    die "Can't create $tmpdir/$gateways: $!";
     279            }
     280        }
     281        else {
     282            warn "Gateways given (and ignored) for testbed not in use: " .
     283                "$gateways\n";
     284            $gateways = 0;
     285        }
     286        next;
     287    };
     288    /^#\s+End\s+gateways\s+\((\w+)\)/ && do {
     289        die "Mismatched gateway markers ($1, $gateways)\n"
     290            unless !$gateways || $gateways == $1;
     291        $gateways = 0;
     292        next;
     293    };
    238294    # Beginning of the hostnames list.  Collection is always in the hostnames
    239295    # file.
    240296    /^#\s+Begin\s+hostnames/ && do {
    241         $destfile = "./hostnames";
     297        $destfile = "$tmpdir/hostnames";
    242298        open(FILE, ">$destfile") || die "Can't open $destfile:$!\n";
    243299        next;
     
    249305        next;
    250306    };
     307
     308    # Generate gateway configuration info, one file per line
     309    $gateways && do {
     310        chomp;
     311        my($dtb, $myname, $desthost, $type) = split(" ", $_);
     312        my($sdomain) = $domain{$gateways};      # domain for the source
     313        my($ddomain) = $domain{$dtb};           # domain for the destination
     314
     315        # If either end of this link is in the master side of the testbed, that
     316        # side is the active end. Otherwise the first testbed encountered in
     317        # the file will be the active end.  The $active_end variable keeps
     318        # track of those decisions
     319        if ( $dtb eq $master ) { $active = "false"; }
     320        elsif ($gateways eq $master ) { $active = "true"; }
     321        elsif ( $active_end{"$dtb-$gateways"} ) { $active="false"; }
     322        else { $active_end{"$gateways-$dtb"}++; $active = "true"; }
     323
     324        # Write out the file
     325        open(GWCONFIG, ">$tmpdir/$gateways/$myname$sdomain.gw.conf") ||
     326            die "can't open $tmpdir/%gateways/$myname$sdomain.gw.conf: $!\n";
     327        print GWCONFIG "Active: $active\n";
     328        print GWCONFIG "Type: $type\n";
     329        print GWCONFIG "Peer: $desthost$ddomain\n";
     330        print GWCONFIG "Pubkeys: /placeholder\n";
     331        print GWCONFIG "Privkeys: /placeholder\n";
     332        close(GWCONFIG);
     333
     334        #done processing gateway entry, ready for next line
     335        next;
     336    };
     337
    251338
    252339    next unless $destfile;  # Unidentified testbed, ignore config
     
    352439testbed.
    353440
     441=item host
     442
     443The host name of the testbed's ops node.  The user calling B<splitter.pl> must
     444be able to execute commands on this host via L<ssh(1)>.
     445
     446=item domain
     447
     448The domain of nodes in this testbed (including the ops host).
     449
    354450=item project
    355451
Note: See TracChangeset for help on using the changeset viewer.