Commit a5c1e591 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Checkpoint the client side of ElabInElab changes in case some whacko is

dying to see whats going on. These changes can go into new images; it will
be ignored in non ElabInElab experiments;

rc.inelab: A terrible hack that I now regret. The whole point of this
script to allow inner boss/ops to 1) play by the standard state machine goo
(ISUP) for the outer emulab. That way os_setup, node_reboot, etc all work
when dealing with setting up the inner elab. 2) Since the inner
control can fall on any of the interfaces (as picked by assign), we
need to still do ifc/route configuration using tmcd. At the time I did
this, I expected that swapmod/swapin/swapout would be possible and
that boss/ops would be coming in on different nodes using different
interfaces for the inner control net, and that I would want to ask
each reboot. Well, I think swapping an inner emulab is a really long
way off, maybe so far off I'll be retired by that time.

rc.mkelab: A lot of very ugly code that turns a node into an inner ops
or boss. I won't bother to describe this code other than to say the
operating model for this rev is to create a fully functional inner
emulab based on the DB state provided by the outer emulab. Currently,
the current testbed software is expected to be in the /proj tree, and
a full boss/ops install is done, followed by all kinds of
customizations (like building accounts for members of the project,
etc) to make it a fully function emulab with just a single project;
the project in which the inner emulab was created.
parent c2e5c83b
......@@ -95,6 +95,7 @@ local-script-install: common-script-install
$(INSTALL) -m 755 $(SRCDIR)/rc.bootsetup $(RCDIR)/rc.bootsetup
$(INSTALL) -m 755 $(SRCDIR)/rc.slothd $(RCDIR)/rc.slothd
$(INSTALL) -m 755 $(SRCDIR)/rc.linktest $(RCDIR)/rc.linktest
$(INSTALL) -m 755 $(SRCDIR)/rc.inelab $(RCDIR)/rc.inelab
# Symlink this cause we invoke it from boss, and its too much
# of a hassle to worry about right now.
rm -f $(ETCDIR)/update
......
......@@ -20,7 +20,7 @@ SUBDIR = tmcd/common/config
SCRIPTS = $(addprefix $(SRCDIR)/, \
rc.config rc.misc rc.mounts rc.accounts rc.route \
rc.tunnels rc.ifconfig rc.delays rc.hostnames \
rc.syncserver rc.linkagent rc.localize \
rc.syncserver rc.linkagent rc.mkelab rc.localize \
rc.keys rc.trafgen rc.tarfiles rc.rpms rc.progagent \
rc.startcmd rc.simulator rc.topomap rc.firewall)
......
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
#
# This script is run directly from boot. It should NOT be run after
# that since some stuff is not setup to properly restart yet. For
# general reconfig or update, use rc.config instead.
#
sub usage()
{
print "Usage: " . scriptname() . "[-b] boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "b";
my $background = 0;
my $action = "boot";
# Turn off line buffering on output
$| = 1;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# Only root.
if ($EUID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
# Script specific goo.
my $RCDIR = "$BINDIR/rc";
my $LOGFILE = "$LOGDIR/bootsetup.debug";
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
use libtmcc;
use librc;
# XXX This is the outer bossname. We use an IP so we are not dependent
# on the nameserver. The route to boss will have been added by DHCP on
# the outer control network.
if (! -e "$ETCDIR/outer_bossnode") {
die("*** $0:\n".
" $ETCDIR/outer_bossnode does not exist!\n");
}
my $bossname = `cat $ETCDIR/outer_bossnode`;
chomp($bossname);
$ENV{'BOSSNAME'} = "$bossname";
# Allow for portnum
if ($bossname =~ /^([\w\.]+)$/) {
libtmcc::configtmcc("server", $1);
}
elsif ($bossname =~ /^([\w\.]+):(\d+)$/) {
# For debugging using my own tmcd. See rc.mkelab.
libtmcc::configtmcc("server", $1);
libtmcc::configtmcc("portnum", $2);
$bossname = $1;
}
# Brutal. Inner elab will have its own certs, and so talk to outer elab
# without SSL, since tmcd does not require SSL on local nodes.
libtmcc::configtmcc("nossl", 1);
$ENV{'TMCCNOSSL'} = "1";
#
# More brutal hackery. We need to establish a route to boss, but DHCP
# static-routes option is broken! Do it here so that tmcc to outer boss
# can find it way.
#
if (! -e "$ETCDIR/outer_router") {
die("*** $0:\n".
" $ETCDIR/outer_router does not exist!\n");
}
my $routerip = `cat $ETCDIR/outer_router`;
chomp($routerip);
system("route add $bossname $routerip");
if ($?) {
die("*** $0:\n".
" Could not establish route to outer boss ($bossname)!\n");
}
# Protos.
sub doboot();
sub doshutdown();
sub doreconfig();
sub docleanup();
# Parse command line.
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'b'})) {
$background = 1;
}
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
# Execute in background and return immediately.
if ($background && TBBackGround($LOGFILE)) {
print "Node reconfiguration started ...\n";
exit(0);
}
# Execute the action.
SWITCH: for ($action) {
/^boot$/i && do {
doboot();
last SWITCH;
};
/^shutdown$/i && do {
doshutdown();
last SWITCH;
};
/^reconfig$/i && do {
doreconfig();
last SWITCH;
};
/^reset$/i && do {
docleanup();
last SWITCH;
};
fatal("Invalid action: $action\n");
}
exit(0);
#
# Boot Action.
#
sub doboot()
{
#
# Check for an os dependent initialization script.
#
my $os_script = "rc." . lc($OSNAME);
if (-x "$RCDIR/$os_script") {
system("$RCDIR/$os_script");
if ($?) {
fatal("Error running $RCDIR/$os_script");
}
}
#
# Check for kernel rename first. Probably not required so early.
#
if (-x "$RCDIR/rc.kname") {
system("$RCDIR/rc.kname");
if ($?) {
fatal("Error running $RCDIR/rc.kname");
}
}
print("Informing Emulab Control that we have rebooted\n");
if (tmcc(TMCCCMD_STATE, "TBSETUP") < 0) {
fatal("Error sending TBSETUP to Emulab Control!");
}
# Now we get into the real work.
print("Checking Testbed reservation status\n");
my ($pid, $eid, $vname) = bootsetup();
if (!defined($pid)) {
goto isfree;
}
#
# We run just two scripts. This sets up the interfaces for the inner
# boss and ops since they will not get it from DHCP, and it is not
# possible to hardwire the info in /etc/rc.conf since assign can pick
# any node, any interface, etc.
#
my @scripts = ("rc.route", "rc.ifconfig");
foreach my $script (@scripts) {
next
if (!-x "$BINDIR/rc/$script");
TBDebugTimeStamp("running $BINDIR/rc/$script");
system("$BINDIR/rc/$script boot");
if ($?) {
fatal("Failed running $BINDIR/rc/$script");
}
}
isfree:
# Now send ISUP
print("Informing Emulab Control that we are up and running\n");
if (tmcc(TMCCCMD_STATE, "ISUP") < 0) {
fatal("Error sending ISUP to Emulab Control!");
}
}
#
# Shutdown Action.
#
sub doshutdown()
{
print("Informing Emulab Control that we are are rebooting\n");
if (tmcc(TMCCCMD_STATE, "SHUTDOWN") < 0) {
fatal("Error sending SHUTDOWN to Emulab Control!");
}
}
#
# Node Reconfig Action (without rebooting).
#
sub doreconfig()
{
print("Informing Emulab Control that we are doing a reconfig\n");
if (tmcc(TMCCCMD_STATE, "TBSETUP") < 0) {
fatal("Error sending TBSETUP to Emulab Control!");
}
sleep(1);
#
# And (re)boot vnodes. As with boot, doing it after ISUP is better;
# os_setup will consider the node ready, and move onto waiting for
# vnodes to boot.
#
print("Informing Emulab Control that we are back up and running\n");
if (tmcc(TMCCCMD_STATE, "ISUP") < 0) {
fatal("Error sending ISUP to Emulab Control!");
}
return 0;
}
#
# Node cleanup action (node is reset to completely clean state).
#
sub docleanup()
{
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment