Commit 509a5736 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 ee12b0af 77dfb2fd
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
......@@ -88,15 +87,7 @@ if ($diff) {
The sitevariables from $master_sitevars differs from
the running database. As a safety measure, you will not be able to install
until this is resolved.
If you are a user of the emulab software outside of Utah, this is probably
because your site variables have not been updated since the installation
of an older version of the emulab software.
Contact testbed-ops\@emulab.net for help in updating your database.
If you're a developer at Utah, this is probably because you (or someone else)
forgot to update sql/sitevars-create.sql .
until this is resolved. Please see the SQL statements above.
EOSTR
......
......@@ -198,6 +198,8 @@ sub Create($$$$$$)
push(@insert_data, "creator_uuid='$owner_uuid'");
push(@insert_data, "slice_uuid='$slice_uuid'");
push(@insert_data, "type='$aggregate_type'");
# Start out new aggregates, as new.
push(@insert_data, "state='new'");
# Insert into DB.
if (!DBQueryWarn("insert into geni_aggregates set " .
......@@ -740,8 +742,9 @@ sub Start($$$)
print STDERR "Could not get sliver list for $self\n";
return -1;
}
my %pnodes = ();
my %vnodes = ();
my %reboots = ();
my %vnodes = ();
my %poweron = ();
foreach my $sliver (@slivers) {
next
......@@ -769,10 +772,19 @@ sub Start($$$)
$vnodes{$node->node_id} = $node;
}
else {
# node_reboot is smart enough to know that if a pnode
# is rebooted it can ignore the vnodes on it, so do
# not optimize this here.
$pnodes{$node->node_id} = $node;
#
# Look to see if local physical node was stopped (powered off).
#
if (!$node->isremotenode() &&
$sliver->state() eq "stopped") {
$poweron{$node->node_id} = $node;
}
else {
# node_reboot is smart enough to know that if a pnode
# is rebooted it can ignore the vnodes on it, so do
# not optimize this here.
$reboots{$node->node_id} = $node;
}
}
}
else {
......@@ -787,7 +799,8 @@ sub Start($$$)
#
my %tmp = %vnodes;
foreach my $vnode (values(%vnodes)) {
if (!exists($pnodes{$vnode->phys_nodeid()})) {
if (! (exists($reboots{$vnode->phys_nodeid()}) ||
exists($poweron{$vnode->phys_nodeid()}))) {
$tmp{$vnode->node_id()} = $vnode;
}
}
......@@ -831,10 +844,21 @@ sub Start($$$)
}
#
# Now reboot the physical nodes, then any leftover virtual nodes.
# First power on any physical nodes that had been stopped.
# Then reboot the physical nodes, then any leftover virtual nodes.
#
if (keys(%pnodes)) {
my @node_ids = keys(%pnodes);
if (keys(%poweron)) {
my @node_ids = keys(%poweron);
#
# Should waiting be an option?
#
system("$POWER on @node_ids");
return -1
if ($?);
}
if (keys(%reboots)) {
my @node_ids = keys(%reboots);
#
# Should waiting be an option?
......@@ -901,7 +925,7 @@ sub Stop($$)
}
my $reservation = $node->Reservation();
if (!defined($reservation)) {
print STDERR "$node no long belongs to $self\n";
print STDERR "$node no longer belongs to $self\n";
return -1;
}
if ($reservation->SameExperiment($experiment)) {
......@@ -910,7 +934,7 @@ sub Stop($$)
# in the stopped state. Skip those.
#
next
if ($sliver->state() eq "started");
if ($sliver->state() eq "stopped");
if ($node->isvirtnode()) {
$vnodes{$node->node_id} = $node;
......@@ -1099,7 +1123,7 @@ sub ComputeState($)
if ($state eq "started") {
$started++;
}
elsif ($state eq "stopped") {
elsif ($state eq "stopped" || $state eq "new") {
$stopped++;
}
else {
......
......@@ -826,6 +826,10 @@ sub SliverStatus($)
my $status = $sliver->status();
my $error = "";
# New is the same as stopped. Separate state is handy.
$state = "stopped"
if ($state eq "new");
if ($status eq "failed") {
$error = $sliver->ErrorLog();
}
......
......@@ -255,10 +255,6 @@ sub CreatePhysNode($)
print STDERR "Invalid hrn '$hrn' in blob from CM for $node_urn\n";
goto bad;
}
if (! ($IP =~ /^[-\w\.]*$/)) {
print STDERR "Invalid IP '$IP' in blob from CM for $node_urn\n";
goto bad;
}
if (! ($uuid =~ /^[-\w\.]*$/)) {
print STDERR "Invalid uuid '$uuid' in blob from CM for $node_urn\n";
goto bad;
......@@ -281,8 +277,21 @@ sub CreatePhysNode($)
#
if (exists($blob->{'interfaces'})) {
foreach my $ref (@{ $blob->{'interfaces'} }) {
if ($ref->{'role'} eq TBDB_IFACEROLE_CONTROL() ||
$ref->{'role'} eq TBDB_IFACEROLE_EXPERIMENT()) {
my $role = $ref->{'role'};
if ($role eq "ctrl" || $role eq "control") {
$IP = $ref->{'IP'};
#
# This turns out to be a problem; if the node is actually
# on the local cluster (we treat all protogeni nodes same),
# we end up with two nodes in the interfaces table with the
# same IP; not allowed since stuff breaks (bootinfo, tmcd).
#
next;
}
if ($role eq TBDB_IFACEROLE_CONTROL() ||
$role eq TBDB_IFACEROLE_EXPERIMENT()) {
my $MAC = $ref->{'MAC'};
if (!defined($MAC) || !($MAC =~ /^[:\w]*$/)) {
print STDERR "Bad mac in blob for $node_urn:\n";
......@@ -337,6 +346,17 @@ sub CreatePhysNode($)
}
elsif ($role eq "ctrl" || $role eq "control") {
$role = TBDB_IFACEROLE_CONTROL();
my $ipv4 = GeniXML::GetText("public_ipv4", $ref);
$IP = $ipv4;
#
# This turns out to be a problem; if the node is actually
# on the local cluster (we treat all protogeni nodes same),
# we end up with two nodes in the interfaces table with the
# same IP; not allowed since stuff breaks (bootinfo, tmcd).
#
next;
}
else {
print STDERR "Unknown role $role for $node_urn!\n";
......@@ -370,10 +390,14 @@ sub CreatePhysNode($)
print STDERR "No interfaces in blob for $node_urn!\n";
goto bad;
}
if (!defined($ctrliface)) {
if (!defined($IP)) {
print STDERR "No control interface in blob for $node_urn!\n";
goto bad;
}
if (! ($IP =~ /^[-\w\.]*$/)) {
print STDERR "Invalid IP '$IP' in blob from CM for $node_urn\n";
goto bad;
}
my $newnode = Node->Create($node_id, undef,
{"role" => "testnode",
"type" => "pcfedphys",
......
......@@ -210,6 +210,8 @@ sub Create($$$$$$$$$)
push(@insert_data, "resource_id='$resource_id'");
push(@insert_data, "creator_uuid='$owner_uuid'");
push(@insert_data, "slice_uuid='$slice_uuid'");
# Start out new slivers, as new.
push(@insert_data, "state='new'");
if (defined($rspec)) {
my $rspec_string = GeniXML::Serialize($rspec);
......@@ -571,7 +573,8 @@ use Experiment;
use emutil;
use XML::Simple;
use libdb qw(TBDB_ALLOCSTATE_RES_INIT_DIRTY TBDB_NODESTATE_SHUTDOWN
TBResolveNextOSID TBDB_NODESTATE_ISUP TBDB_NODESTATE_TBFAILED);
TBResolveNextOSID TBDB_NODESTATE_ISUP TBDB_NODESTATE_TBFAILED
TBDB_NODESTATE_PXEWAIT);
# Error log for local physical node.
sub ErrorLog($)
......@@ -668,7 +671,8 @@ sub Create($$$$$$)
$sliver_uuid = $vnode->uuid();
$resource_id = $vnode->node_id();
$hostname = GeniUtil::FindHostname($vnode->node_id());
$sshdport = $vnode->sshdport();
$sshdport = $vnode->sshdport()
if (!defined($vnode->jailip()));
}
else {
$hrn = "${PGENIDOMAIN}." . $node->node_id();
......@@ -867,6 +871,14 @@ sub UnProvision($;$)
$node->ModifyReservation({"genisliver_idx" => 0});
goto skip;
}
#
# Look to see if local physical node was stopped (powered off).
#
if (!$node->isvirtnode() &&
!$node->isremotenode() &&
$self->state() eq "stopped") {
system("$POWER on $node_id");
}
system("$NFREE -q $pid $eid $node_id");
}
if ($?) {
......@@ -991,7 +1003,17 @@ sub Start($$$)
}
}
else {
system("$NODEREBOOT -s $node_id");
#
# Look to see if local physical node was stopped (powered off).
#
if (!$node->isvirtnode() &&
!$node->isremotenode() &&
$self->state() eq "stopped") {
system("$POWER on $node_id");
}
else {
system("$NODEREBOOT -s $node_id");
}
}
return -1
if ($?);
......@@ -1098,7 +1120,8 @@ sub ComputeStatus($$)
elsif ($eventstate eq TBDB_NODESTATE_TBFAILED()) {
$status = "failed";
}
elsif ($eventstate eq TBDB_NODESTATE_SHUTDOWN()) {
elsif ($eventstate eq TBDB_NODESTATE_SHUTDOWN() ||
$eventstate eq TBDB_NODESTATE_PXEWAIT()) {
$status = "notready";
}
else {
......
......@@ -759,9 +759,14 @@ sub send_mail($$@) {
# Given a full refname, pull off the last part for pretty printing
#
sub short_refname($) {
my ($refname) = @_;
$refname =~ /([^\/]+)$/;
return $1;
my ($ref) = @_;
my $refname = `git rev-parse --abbrev-ref $ref $STDERRNULL`;
chomp $refname;
# This shouldn't be necessary, but return the full ref if
# rev-parse doesn't return anything.
$refname = $ref if (!$refname);
return $refname;
}
#
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# Copyright (c) 2008, 2010 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
......@@ -19,18 +19,20 @@ sub usage()
print STDOUT "-r Show only traffic received by each node\n";
print STDOUT "-s Show only traffic sent by each node\n";
print STDOUT "-i seconds Show stats over a <seconds>-period interval\n";
print STDOUT "-E Aggregate by experiment\n";
# print STDOUT "-C Show control net traffic\n";
exit(-1);
}
sub gather($$);
my $optlist = "Ci:ars";
my $optlist = "CEi:ars";
my $debug = 0;
my $interval = 0;
my $doall = 0;
my $send = 1;
my $recv = 1;
my $byexpt = 0;
# XXX only does control net right now
my $controlnet = 1;
......@@ -95,6 +97,9 @@ if (defined($options{"i"})) {
die("Bogus interval $interval\n");
}
}
if (defined($options{"E"})) {
$byexpt = 1;
}
if (defined($options{"C"})) {
$controlnet = 1;
}
......@@ -141,6 +146,8 @@ if ($interval > 0) {
my %after = ();
gather(\%pcs, \%after);
my %expcounts = ();
# weed out bad boys
my @list = ();
foreach my $node (keys %pcs) {
......@@ -164,21 +171,56 @@ foreach my $node (keys %pcs) {
}
$pcs{$node}{'total'} = $total;
push(@list, $node);
if ($byexpt) {
my $cb = $before{$node}{'totals'};
my $ca = $after{$node}{'totals'};
my $exp = $pcs{$node}{'exp'};
if (!exists($expcounts{$exp})) {
$expcounts{$exp} = [ 0, 0, 0, 0 ];
}
$expcounts{$exp}->[0] += ($ca->[0] - $cb->[0]);
$expcounts{$exp}->[1] += ($ca->[1] - $cb->[1]);
$expcounts{$exp}->[2] += ($ca->[2] - $cb->[2]);
$expcounts{$exp}->[3] += ($ca->[3] - $cb->[3]);
}
}
if ($byexpt) {
printf("%25s %12s %12s %12s %12s\n",
"Experiment", "Tot Pkts", "Unicast", "Non-Uni", "Tot Bytes");
foreach my $exp (sort esortem keys %expcounts) {
printf("%25s %12d %12d %12d %12d\n",
$exp, $expcounts{$exp}->[3],
$expcounts{$exp}->[1],
$expcounts{$exp}->[2],
$expcounts{$exp}->[0]);
}
} else {
@list = sort sortem @list;
printf("%12s %25s %12s %12s %12s %12s\n",
"Node", "Experiment", "Tot Pkts", "Unicast", "Non-Uni", "Tot Bytes");
foreach my $node (@list) {
my $cb = $before{$node}{'totals'};
my $ca = $after{$node}{'totals'};
my $exp = $pcs{$node}{'exp'};
my $s = $pcs{$node}{'state'};
printf("%12s %25s %12d %12d %12d %12d\n",
$node, $exp,
$ca->[3]-$cb->[3], $ca->[1]-$cb->[1],
$ca->[2]-$cb->[2], $ca->[0]-$cb->[0]);
}
}
@list = sort sortem @list;
printf("%12s %25s %12s %12s %12s %12s\n",
"Node", "Experiment", "Tot Pkts", "Unicast", "Non-Uni", "Tot Bytes");
foreach my $node (@list) {
my $cb = $before{$node}{'totals'};
my $ca = $after{$node}{'totals'};
my $exp = $pcs{$node}{'exp'};
my $s = $pcs{$node}{'state'};
sub esortem($$)
{
my ($a, $b) = @_;
printf("%12s %25s %12d %12d %12d %12d\n",
$node, $exp,
$ca->[3]-$cb->[3], $ca->[1]-$cb->[1],
$ca->[2]-$cb->[2], $ca->[0]-$cb->[0]);
my $atot = $expcounts{$a}->[3];
my $btot = $expcounts{$b}->[3];
return $btot <=> $atot;
}
sub sortem($$)
......
......@@ -947,7 +947,7 @@ function DOLOGIN($token, $password, $adminmode = 0) {
function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
{
global $TBAUTHCOOKIE, $TBAUTHDOMAIN, $TBAUTHTIMEOUT;
global $TBAUTHCOOKIE, $TBAUTHDOMAIN, $TBAUTHTIMEOUT, $WWWHOST;
global $TBNAMECOOKIE, $TBLOGINCOOKIE, $TBSECURECOOKIES, $TBEMAILCOOKIE;
global $TBMAIL_OPS, $TBMAIL_AUDIT, $TBMAIL_WWW;
global $WIKISUPPORT, $WIKICOOKIENAME;
......@@ -979,6 +979,16 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
# Issue the cookie requests so that subsequent pages come back
# with the hash value and auth usr embedded.
#
# Since we changed the domain of the cookies make sure that the cookies
# from the old domain no longer exist.
#
setcookie($TBAUTHCOOKIE, '', 1, "/", $TBAUTHDOMAIN, $TBSECURECOOKIES);
setcookie($TBLOGINCOOKIE, '', 1, "/", $TBAUTHDOMAIN, 0);
setcookie($TBNAMECOOKIE, '', 1, "/", $TBAUTHDOMAIN, 0);
if ($email)
setcookie($TBEMAILCOOKIE, '', 1, "/", $TBAUTHDOMAIN, 0);
#
# For the hashkey, we use a zero timeout so that the cookie is
# a session cookie; killed when the browser is exited. Hopefully this
......@@ -987,7 +997,7 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
# at the server so it will become invalid at some point.
#
setcookie($TBAUTHCOOKIE, $hashkey, 0, "/",
$TBAUTHDOMAIN, $TBSECURECOOKIES);
$WWWHOST, $TBSECURECOOKIES);
#
# Another cookie, to help in menu generation. See above in
......@@ -996,14 +1006,14 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
# All this does is change the menu options presented, imparting
# no actual privs.
#
setcookie($TBLOGINCOOKIE, $crc, 0, "/", $TBAUTHDOMAIN, 0);
setcookie($TBLOGINCOOKIE, $crc, 0, "/", $WWWHOST, 0);
#
# We want to remember who the user was each time they load a page
# NOTE: This cookie is integral to authorization, since we do not pass
# around the UID anymore, but look for it in the cookie.
#
setcookie($TBNAMECOOKIE, $uid_idx, 0, "/", $TBAUTHDOMAIN, 0);
setcookie($TBNAMECOOKIE, $uid_idx, 0, "/", $WWWHOST, 0);
#
# This is a long term cookie so we can remember who the user was, and
......@@ -1011,7 +1021,7 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
#
if ($email) {
$timeout = $now + (60 * 60 * 24 * 365);
setcookie($TBEMAILCOOKIE, $email, $timeout, "/", $TBAUTHDOMAIN, 0);
setcookie($TBEMAILCOOKIE, $email, $timeout, "/", $WWWHOST, 0);
}
#
......@@ -1082,7 +1092,7 @@ function VERIFYPASSWD($uid, $password) {
#
function DOLOGOUT($user) {
global $CHECKLOGIN_STATUS, $CHECKLOGIN_USER;
global $TBAUTHCOOKIE, $TBLOGINCOOKIE, $TBAUTHDOMAIN;
global $TBAUTHCOOKIE, $TBLOGINCOOKIE, $TBAUTHDOMAIN, $WWWHOST;
global $WIKISUPPORT, $WIKICOOKIENAME, $HTTP_COOKIE_VARS;
global $BUGDBSUPPORT, $BUGDBCOOKIENAME, $TRACSUPPORT, $TRACCOOKIENAME;
......@@ -1140,8 +1150,8 @@ function DOLOGOUT($user) {
#
$timeout = time() - 3600;
setcookie($TBAUTHCOOKIE, "", $timeout, "/", $TBAUTHDOMAIN, 0);
setcookie($TBLOGINCOOKIE, "", $timeout, "/", $TBAUTHDOMAIN, 0);
setcookie($TBAUTHCOOKIE, "", $timeout, "/", $WWWHOST, 0);
setcookie($TBLOGINCOOKIE, "", $timeout, "/", $WWWHOST, 0);
if ($TRACSUPPORT) {
setcookie("trac_auth_emulab", "", $timeout, "/",
......
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