Changeset 7c3008e


Ignore:
Timestamp:
May 22, 2008 7:09:10 AM (16 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:
2aeb39e
Parents:
f778038
Message:

checkpoint

Location:
fedkit
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • fedkit/fed_bootstrap

    rf778038 r7c3008e  
    2929# federation script, and run it.
    3030cd /tmp
    31 exec /tmp/federate.sh
     31exec /tmp/federate.sh "$1" "$2"
  • fedkit/federate.sh

    rf778038 r7c3008e  
    166166/usr/local/etc/emulab/rc/rc.route boot
    167167
     168# And restore the ifconfig information because SEER wants it. (SEER pulls this
     169# from tmcc now
     170# "$EMUDIR/tmcc" ifconfig > /var/emulab/boot/tmcc/ifconfig
     171
     172# SEER feels pain and confusion if times are wrong.  This lays a big lick on
     173# ntp sets the time directly and then restarts it.  XXX FreeBSD incantation is
     174# untested.
     175
     176case `uname` in
     177        "FreeBSD")
     178                /etc/rc.d/ntpd stop
     179                /usr/sbin/ntpdate boss
     180                /etc/rc.d/ntpd start
     181                ;;
     182        "Linux")
     183                /etc/rc.d/init.d/ntpd stop
     184                /usr/sbin/ntpdate boss
     185                /etc/rc.d/init.d/ntpd start
     186                ;;
     187esac
     188
    168189# Execute any command passed in as a startcmd.  This basically daisy chains the
    169 # startcmd.
     190# startcmd.  This needs to become a perl script to have uniform behavior here.
     191echo "*$1* *$2*"
    170192if [ ! -z "$1" ]; then
    171         su -l "$1" -c "$2"
    172 fi
     193        echo "calling *$1* *$2*"
     194        case `uname` in
     195                "FreeBSD")
     196                        su -l "$1" -c "$2"
     197                        ;;
     198                "Linux")
     199                        su "$1" --command="$2"
     200                        ;;
     201        esac
     202fi
  • fedkit/make_hosts

    rf778038 r7c3008e  
    1818/usr/local/etc/emulab/rc/rc.route
    1919
     20# SEER feels pain and confusion if times are wrong.  This lays a big lick on
     21# ntp sets the time directly and then restarts it.  XXX FreeBSD incantation is
     22# untested.
     23
     24case `uname` in
     25        "FreeBSD")
     26                /etc/rc.d/ntpd stop
     27                /usr/sbin/ntpdate boss
     28                /etc/rc.d/ntpd start
     29                ;;
     30        "Linux")
     31                /etc/rc.d/init.d/ntpd stop
     32                /usr/sbin/ntpdate boss
     33                /etc/rc.d/init.d/ntpd start
     34                ;;
     35esac
     36
     37# Execute any command passed in as a startcmd.  This basically daisy chains the
     38# startcmd.  This needs to become a perl script to have uniform behavior here.
     39echo "*$2* *$3*"
    2040if [ ! -z "$2" ]; then
    21         su -l "$2" -c "$3"
     41        echo "calling *$2* *$3*"
     42        case `uname` in
     43                "FreeBSD")
     44                        su -l "$2" -c "$3"
     45                        ;;
     46                "Linux")
     47                        su "$2" --command="$3"
     48                        ;;
     49        esac
    2250fi
  • fedkit/splitter.pl

    rf778038 r7c3008e  
    88use IO::Pipe;
    99use File::Copy;
     10use XML::Parser;
    1011
    1112my @scripts = ("fed_bootstrap", "federate.sh", "smbmount.FreeBSD.pl",
     
    352353        &scp_file("$tmpdir/hostnames", $user, $host, $to_hostname) ||
    353354            return 0;
     355        # Copy the virtual topology out as well
     356        &scp_file("$tmpdir/vtopo.xml", $user, $host, "$proj_dir/vtopo.xml") ||
     357            return 0;
     358        &scp_file("$tmpdir/viz.xml", $user, $host, "$proj_dir/viz.xml") ||
     359            return 0;
    354360        &ship_scripts($host, $user, $proj_dir) || return 0;
    355361        &ship_configs($host, $user, "$tmpdir/$tb", $proj_dir) || return 0;
     
    378384        &scp_file("$tmpdir/hostnames", $user, $host, $to_hostname) ||
    379385            return 0;
     386        # Copy the virtual topology out as well
     387        &scp_file("$tmpdir/vtopo.xml", $user, $host, "$proj_dir/vtopo.xml") ||
     388            return 0;
     389        &scp_file("$tmpdir/viz.xml", $user, $host, "$proj_dir/viz.xml") ||
     390            return 0;
     391        &ship_scripts($host, $user, $proj_dir) || return 0;
    380392        &ship_scripts($host, $user, $proj_dir) || return 0;
    381393        &ship_configs($host, $user, "$tmpdir/$tb", $proj_dir) || return 0;
     
    425437        &scp_file("$tmpdir/hostnames", $user, $host, $to_hostname) ||
    426438            return 0;
     439        # Copy the virtual topology out as well
     440        &scp_file("$tmpdir/vtopo.xml", $user, $host, "$proj_dir/vtopo.xml") ||
     441            return 0;
     442        &scp_file("$tmpdir/viz.xml", $user, $host, "$proj_dir/viz.xml") ||
     443            return 0;
     444        &ship_scripts($host, $user, $proj_dir) || return 0;
    427445        &ship_scripts($host, $user, $proj_dir) || return 0;
    428446        &ship_configs($host, $user, "$tmpdir/$tb", $proj_dir) || return 0;
     
    477495    unlink("/tmp/splitter.$$", "/tmp/splitter.err.$$");
    478496    return $rv;
     497}
     498
     499# Generate visualization info from the topo file.
     500sub genviz {
     501    my($file, $outfile)= @_;
     502    my %nodes;
     503    my $chars;
     504    my $in_node;
     505    my $in_lan;
     506    my $lan;
     507    my %links;
     508    my %lans;
     509    my $rv;
     510    my $dotfile = "/tmp/split$$.dot";
     511    my $neato = "/usr/local/bin/neato";
     512    my $g = new IO::File(">$dotfile") || return;
     513    my $p = new IO::Pipe() || return;
     514    my $out = new IO::File(">$outfile") || die "open $!\n";
     515
     516    sub start_element {
     517        my($expat, $element) = @_;
     518        $in_node++ if $element eq "node";
     519        if ( $element eq "lan" ) {
     520            $in_lan++;
     521            $lan = {};
     522        }
     523    }
     524
     525    sub end_element {
     526        my($expat, $element) = @_;
     527
     528        $in_node = 0 if $element eq "node";
     529        $nodes{$chars} = "node" if $in_node && $element eq "vname";
     530        if ($in_lan) {
     531            if ( $element ne "lan") {
     532                $lan->{$element} = $chars if $element =~/(vname|vnode)/;
     533            }
     534            else {
     535                $in_lan = 0;
     536                my $vname = $lan->{'vname'};
     537                if ( $links{$vname} && @{$links{$vname}} ==2 ) {
     538                    # this link needs to be a lan
     539                    $nodes{$vname} = "lan";
     540                    $lans{$lan->{'vname'}} = ();
     541                    foreach my $l (@{$links{$vname}}) {
     542                        push(@{$lans{$vname}}, $l);
     543                    }
     544                    push(@{$lans{$vname}}, $lan->{'vnode'});
     545                    delete $links{$vname};
     546                    $lan={};
     547                    return;
     548                }
     549                if ( $lans{$vname} && @{$lans{$vname}}) {
     550                    push(@{$lans{$vname}}, $lan->{'vnode'});
     551                    $lan = {};
     552                    return;
     553                }
     554                $links{$vname} = () unless $links{$vname};
     555                push(@{$links{$vname}}, $lan->{'vnode'});
     556                $lan = {};
     557                return;
     558            }
     559        }
     560    }
     561    sub found_chars {
     562        my($expat, $data) = @_;
     563        $chars = $data;
     564    }
     565
     566    my $parser = new XML::Parser(Handlers => {
     567            Start => \&start_element,
     568            End => \&end_element,
     569            Char => \&found_chars
     570        });
     571
     572    print "$file\n";
     573    $parser->parsefile($file);
     574
     575    print $g "graph G {\n";
     576    foreach my $n (keys %nodes) {
     577        print $g "\t\"$n\"\n";
     578    }
     579    foreach my $l (keys %links) {
     580        print $g "\t", join(" -- ", @{$links{$l}}), "\n";
     581    }
     582    foreach my $l (keys %lans) {
     583        foreach my $n (@{$lans{$l}}) {
     584            print $g "\t \"$n\" -- \"$l\"\n";
     585        }
     586    }
     587    print $g "}\n";
     588    $g->close();
     589    $p->reader("$neato  -Gstart=rand -Gepsilon=0.005 -Gmaxiter=20000 " .
     590        "-Gpack=true $dotfile");
     591    print $out "<vis>\n";
     592    while (<$p>) {
     593        /^\s*"?([\w\-]+)"?\s+\[.*pos=\"(\d+),(\d+)\"/ && do {
     594            my ($n, $x, $y) = ($1, $2, $3);
     595
     596            print $out "<node><name>$n</name><x>$x</x><y>$y</y><type>" .
     597                "$nodes{$n}</type></node>\n" if $nodes{$n};
     598        };
     599    }
     600    print $out "</vis>\n";
     601    $p->close();
     602    unlink("$dotfile");
    479603}
    480604
     
    583707my %active_end;                 # If active_end{"a-b"} > 0 then a is the active
    584708                                # end of the a <-> b connector pair.
     709my $vtopo;                      # IO::File for virtual topology info
    585710
    586711# Parse the splitter output.  This loop creates the sub experiments, gateway
    587712# configurations and hostnames file
    588713while (<$pipe>) {
    589     # Vtopo is virtual topology about the entire experiment.  Right now ignore
    590     # it.  We'll pass it to SEER soon.
     714    # Vtopo is virtual topology about the entire experiment. Copy it to the
     715    # $tmpdir for distribution far and wide.
    591716    (/^#\s+Begin\s+Vtopo/../^#\s+End\s+Vtopo/) && do {
     717        /^#\s+Begin/ && do {
     718            $vtopo = new IO::File(">$tmpdir/vtopo.xml");
     719            warn "Can't open $tmpdir/vtopo.xml:$!\n" unless $vtopo;
     720            next;
     721        };
     722        /^#\s+End/ && do {
     723            $vtopo->close() if $vtopo;
     724            undef $vtopo;
     725            genviz("$tmpdir/vtopo.xml", "$tmpdir/viz.xml");
     726            next;
     727        };
     728        print $vtopo $_  if $vtopo;
    592729        next;
    593730    };
Note: See TracChangeset for help on using the changeset viewer.