Commit 5b020e2c authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Merge branch 'master' of git-public.flux.utah.edu:/flux/git/emulab-devel

parents 2e5cfc98 02239074
......@@ -49,15 +49,12 @@ my $CONTROL = "@USERNODE@";
my $DBNAME = "@TBDBNAME@";
my $TBOPSPID = TBOPSPID();
my $SSH = "$TB/bin/sshtb";
my $SCP = "/usr/bin/scp";
my $nodereboot = "$TB/bin/node_reboot";
my $makeconf = "$TB/sbin/dhcpd_makeconf";
my $nodewait = "$TB/sbin/node_statewait";
my $snmpit = "$TB/bin/snmpit";
# Locals
my $elabinelab;
my $elabinelab_eid;
# Protos
sub TearDownEmulab();
sub RemoveNodes();
......@@ -170,10 +167,11 @@ TBDebugTimeStampsOn();
# Get elabinelab status to make sure, and to see if we need to fire off
# an experiment inside once its setup.
#
if (! TBExptIsElabInElab($pid, $eid, \$elabinelab, \$elabinelab_eid)) {
die("*** $0:\n".
" Could not get elabinelab status for experiment $pid/$eid\n");
}
my $elabinelab = $experiment->elabinelab();
my $elabinelab_eid = $experiment->elabinelab_eid();
my $elabinelab_nosetup = $experiment->elabinelab_nosetup();
my $elabinelab_singlenet = $experiment->elabinelab_singlenet();
exit(0)
if (!$elabinelab);
......@@ -183,15 +181,6 @@ exit(0)
my $firewall;
my $firewalled = TBExptFirewall($pid, $eid, \$firewall);
#
# XXX NOSETUP option needs more work ...
#
$query_result =
DBQueryFatal("select elabinelab_nosetup,elabinelab_singlenet ".
" from experiments ".
"where pid='$pid' and eid='$eid'");
my ($nosetup,$singlenet) = $query_result->fetchrow_array();
#
# Presetup; turn off firewall.
#
......@@ -374,7 +363,7 @@ $UID = $SAVEUID;
$EUID = $UID;
goto skipsetup
if ($nosetup);
if ($elabinelab_nosetup);
#
# Restart DHCPD, but first mark the nodes as being ready to boot inside
......@@ -839,7 +828,7 @@ sub DumpDBGoo()
or die("*** $0:\n".
" Could not create temporary table temp_interfaces\n");
if (! $singlenet) {
if (! $elabinelab_singlenet) {
# First, mark the real control network as "other" to avoid it being
# thought of as the control network!.
DBQueryWarn("update temp_interfaces ".
......@@ -885,7 +874,7 @@ sub DumpDBGoo()
"left join virt_nodes as v on v.vname=r.vname and ".
" v.pid=r.pid and v.eid=r.eid ".
"left join wires as t on t.node_id1=r.node_id ".
($singlenet == 0 ? " and t.type='Node' " : " ") .
($elabinelab_singlenet == 0 ? " and t.type='Node' " : " ") .
"where r.pid='$pid' and r.eid='$eid' and ".
" v.inner_elab_role in ('node','ops','fs','ops+fs') ")
or die("*** $0:\n".
......@@ -903,7 +892,7 @@ sub DumpDBGoo()
or die("*** $0:\n".
" Could not ops node_id in temp_wires\n");
if (! $singlenet) {
if (! $elabinelab_singlenet) {
# But we need to take out the wires that are being used as the
# inner control network, or at least mark them as Control.
$query_result =
......@@ -1363,9 +1352,11 @@ sub RemoveNodes()
sub UpdateEmulab()
{
my $tbdir = "/usr/testbed";
my $statedir = "$workdir/elabinelab";
my $wap = "$tbdir/sbin/withadminprivs";
my $nodereboot = "$tbdir/bin/node_reboot";
my $nodewait = "$tbdir/sbin/node_statewait";
my $creator = $experiment->creator();
my @nodes = ();
my $paniced = 0;
......@@ -1390,17 +1381,107 @@ sub UpdateEmulab()
# Grab the list of nodes that have been added to the inner elab.
#
my $query_result =
DBQueryFatal("select node_id from reserved ".
"where pid='$pid' and eid='$eid' and ".
" inner_elab_boot=0 and inner_elab_role='node'");
while (my ($node) = $query_result->fetchrow_array()) {
push(@nodes, $node);
DBQueryFatal("select r.node_id,n.type,i.IP from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"left join interfaces as i on i.node_id=r.node_id and ".
" i.role='" . TBDB_IFACEROLE_CONTROL() . "' ".
"where r.pid='$pid' and r.eid='$eid' and ".
" r.inner_elab_boot=0 and r.inner_elab_role='node'");
return 0
if (!$query_result->numrows);
DBQueryFatal("create temporary table temp_new_nodes like new_nodes");
DBQueryFatal("create temporary table temp_new_interfaces ".
" like new_interfaces");
my %idmap = ();
while (my ($node,$type,$ip) = $query_result->fetchrow_array()) {
my $result =
DBQueryFatal("insert into temp_new_nodes set ".
" new_node_id=NULL, node_id='$node', ".
" type='$type', IP='$ip'");
$idmap{$node} = $result->insertid;
}
@nodes = keys(%idmap);
$query_result =
DBQueryFatal("select r.node_id,i.ip,i.role,i.card,i.mac, ".
" i.interface_type,w.node_id2,w.card2,w.port2 ".
" from reserved as r ".
"left join interfaces as i on i.node_id=r.node_id ".
"left join wires as w on w.node_id1=i.node_id and ".
" w.card1=i.card and w.port1=i.port ".
"where r.pid='$pid' and r.eid='$eid' and ".
" r.inner_elab_boot=0 and r.inner_elab_role='node'");
while (my ($node,$ip,$role,$card,$mac,$type,$switch,
$switch_card,$switch_port) = $query_result->fetchrow_array()) {
my $nid = $idmap{$node};
if (! $elabinelab_singlenet) {
#
# Mark the real control network as "other" to avoid it being
# thought of as the control network.
#
if ($role eq TBDB_IFACEROLE_CONTROL()) {
$role = TBDB_IFACEROLE_OUTER_CONTROL();
}
# And mark the inner control network.
if ($role eq TBDB_IFACEROLE_EXPERIMENT() &&
defined($ip) && $ip ne "") {
$role = TBDB_IFACEROLE_CONTROL();
}
}
DBQueryFatal("insert into temp_new_interfaces set ".
" new_node_id='$nid', role='$role', card='$card', ".
" mac='$mac', interface_type='$type', ".
" switch_id='$switch',switch_card='$switch_card', ".
" switch_port='$switch_port'");
}
unlink("$statedir/new_nodes");
DBQueryFatal("select * from temp_new_nodes ".
"into outfile '$statedir/new_nodes'");
unlink("$statedir/new_interfaces");
DBQueryFatal("select * from temp_new_interfaces ".
"into outfile '$statedir/new_interfaces'");
return 0
if (!@nodes);
if ($dbgooonly);
# For SSH and SCP below
$UID = 0;
#
# Send the new_nodes and new_interfaces tables over to the
# inner elab.
#
print "Sending new DB tables to inner boss ($bossnode)\n";
system("$SCP $statedir/new_nodes $statedir/new_interfaces ".
" ${bossnode}:/tmp");
if ($?) {
print STDERR "*** $0:\n".
" Could not scp tables to inner boss\n";
return -1;
}
system("$SSH -host $bossnode mysqlimport -r tbdb ".
" /tmp/new_nodes /tmp/new_interfaces");
if ($?) {
print STDERR "*** $0:\n".
" Could not load tables on inner boss\n";
return -1;
}
print "Telling inner boss ($bossnode) to incorporate new nodes: @nodes\n";
system("$SSH -host $bossnode sudo -u $creator /usr/testbed/sbin/wap ".
" /usr/testbed/sbin/newnode -q -n @nodes");
if ($?) {
print STDERR "*** $0:\n".
" Could not incorporate new nodes on inner boss\n";
return -1;
}
# Run as real user for the next few scripts, which are setuid.
$UID = $SAVEUID;
$EUID = $UID;
#
......
......@@ -174,6 +174,11 @@ if ($ELABINELAB) {
if (!defined($rval)) {
exit(-1);
}
if ($sendevent && ($op eq "off" || $op eq "cycle")) {
foreach my $node (@nodelist) {
TBSetNodeEventState($node, TBDB_NODESTATE_SHUTDOWN);
}
}
exit($rval);
}
......
......@@ -255,7 +255,7 @@ if ($testmode) {
#
# Provide a simple way to grab some commits - the three most recent ones
#
@reflines = ("$testbranch~2 $testbranch refs/heads/$testbranch");
@reflines = ("$testbranch~2 $testbranch $testbranch");
} else {
#
# Get all of the references that are being pushed from stdin - we do this in
......@@ -584,10 +584,18 @@ sub commit_mail($\@$@) {
# and what branch it happened on
#
my $subject = "git commit: ";
my $ref_type;
if (defined($reponame)) {
$subject .= "[$reponame] ";
}
$subject .= "branch " . short_refname($refname);
if ($refname =~ m#refs/tags/#) {
$ref_type = 'tag';
} elsif ($refname =~ m#refs/heads/#) {
$ref_type = 'branch';
}
$subject .= $ref_type . ' ' . short_refname($refname);
if ($ct eq $CT_UPDATE) {
$subject .= " updated";
......@@ -599,7 +607,7 @@ sub commit_mail($\@$@) {
$subject .= " deleted";
}
my $actionstring = "Branch " . short_refname($refname) .
my $actionstring = ucfirst($ref_type) . ' ' . short_refname($refname) .
" has been ${ct}d\n\n";
if ($ct eq $CT_FORCED_UPDATE) {
......@@ -670,6 +678,14 @@ sub get_commits($$$) {
return @revs;
} elsif ($ct eq $CT_CREATE) {
#
# For tags, just return the new revision. This at least tells us
# where the tag points.
#
if ($refname =~ m#^refs/tags/#) {
return ($newrev);
}
#
# If it's a create, we have to be a bit more fancy: we look for all
# commits reachable from the new branch, but *not* reachable from any
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2003-2008 University of Utah and the Flux Group.
# Copyright (c) 2003-2010 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -85,15 +85,22 @@ if (!TBAdmin()) {
sub usage() {
die "Usage: $0 [-f] <node_id> ...\n";
}
my $noreboot = 0;
my $quiet = 0;
my $force_unconnected_interfaces = 0;
my %options = ();
if (! getopts("f", \%options)) {
if (! getopts("fnq", \%options)) {
usage();
}
if ($options{f}) {
$force_unconnected_interfaces = 1;
}
if ($options{'n'}) {
$noreboot = 1;
}
if ($options{'q'}) {
$quiet = 1;
}
#
# We seem to have to do this so that ssh gets proper root permissions to read
......@@ -561,16 +568,19 @@ if ($exports_rv) {
#
# Start rebooting nodes
#
print "Rebooting nodes...\n";
foreach my $IP (@reboot_IPs) {
print "Rebooting $IP\n";
system "$newnode_reboot $IP\n";
if (!$noreboot) {
print "Rebooting nodes...\n";
foreach my $IP (@reboot_IPs) {
print "Rebooting $IP\n";
system "$newnode_reboot $IP\n";
}
}
if (!$quiet) {
print "\n\n";
print "Finished - when you are satisifed that the nodes are working\n";
print "correctly, use nfree on boss to free them from the emulab-ops/hwdown\n";
print "experiment.\n";
}
print "\n\n";
print "Finished - when you are satisifed that the nodes are working\n";
print "correctly, use nfree on boss to free them from the emulab-ops/hwdown\n";
print "experiment.\n";
#
# TODO -
......
Supports Markdown
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