Commit 96dddac9 authored by David Johnson's avatar David Johnson

Multiple plc changes.

parent eb704d6d
...@@ -11,8 +11,7 @@ use Exporter; ...@@ -11,8 +11,7 @@ use Exporter;
use vars qw(@ISA @EXPORT); use vars qw(@ISA @EXPORT);
@ISA = "Exporter"; @ISA = "Exporter";
@EXPORT = qw (MIN TimeStamp getLA OpenLog Log STATUSLOG STATUSLOGPATH @EXPORT = qw (MIN TimeStamp getLA OpenLog Log STATUSLOG STATUSLOGPATH);
getPLCName setPLCName);
# Must come after package declaration! # Must come after package declaration!
use lib '@prefix@/lib'; use lib '@prefix@/lib';
...@@ -30,18 +29,6 @@ my $UPTIME = "/usr/bin/uptime"; ...@@ -30,18 +29,6 @@ my $UPTIME = "/usr/bin/uptime";
# package vars # package vars
my %logs = (); my %logs = ();
my $plcname;
sub setPLCName {
my $tplcname = shift;
if (defined($tplcname)) {
$plcname = $tplcname;
}
}
sub getPLCName {
return $plcname;
}
sub STATUSLOG { sub STATUSLOG {
my $log = shift || ''; my $log = shift || '';
......
...@@ -47,13 +47,16 @@ my $PLABMOND_EID = PLABMOND_EID(); ...@@ -47,13 +47,16 @@ my $PLABMOND_EID = PLABMOND_EID();
my $PLABHOLDING_PID = PLABHOLDING_PID(); my $PLABHOLDING_PID = PLABHOLDING_PID();
my $PLABHOLDING_EID = PLABHOLDING_EID(); my $PLABHOLDING_EID = PLABHOLDING_EID();
my $plcname = '';
sub new($$$$$) { sub new($$$$$) {
# The next two lines are some voodoo taken from perltoot(1) # The next two lines are some voodoo taken from perltoot(1)
my $proto = shift; my $proto = shift;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
my ($poolname, $poolpid, $pooleid, $chpid2pool) = @_; my ($plcid, $poolname, $poolpid, $pooleid, $chpid2pool) = @_;
$plcname = $plcid;
# #
# Create the actual object # Create the actual object
...@@ -249,11 +252,11 @@ sub processchild($$$) { ...@@ -249,11 +252,11 @@ sub processchild($$$) {
delete $self->{'PENDING'}->{$pnode->{'name'}}; delete $self->{'PENDING'}->{$pnode->{'name'}};
if (!$exstat) { if (!$exstat) {
print "Teardown of $pnode->{'vnode'} complete\n"; print "Teardown of $pnode->{'vnode'} complete\n";
Log(STATUSLOG(libplabmon::getPLCName()), Log(STATUSLOG($plcname),
$logmsg . "teardown, success, teardown succeeded."); $logmsg . "teardown, success, teardown succeeded.");
} else { } else {
print "Teardown of $pnode->{'vnode'} failed: $exstat\n"; print "Teardown of $pnode->{'vnode'} failed: $exstat\n";
Log(STATUSLOG(libplabmon::getPLCName()), Log(STATUSLOG($plcname),
$logmsg . "teardown, fail, teardown failed."); $logmsg . "teardown, fail, teardown failed.");
} }
...@@ -302,7 +305,7 @@ sub processchild($$$) { ...@@ -302,7 +305,7 @@ sub processchild($$$) {
$self->teardownnode($pnode); $self->teardownnode($pnode);
$self->calcnextcheck($pnode); $self->calcnextcheck($pnode);
$pnode->{'consecfails'}++; $pnode->{'consecfails'}++;
Log(STATUSLOG(libplabmon::getPLCName()), $logmsg); Log(STATUSLOG($plcname), $logmsg);
} else { } else {
# Instantiation was successful. # Instantiation was successful.
# Setup a timeout to wait for ISUP. # Setup a timeout to wait for ISUP.
...@@ -330,7 +333,7 @@ sub checkexpiration($) { ...@@ -330,7 +333,7 @@ sub checkexpiration($) {
# Yes! Node is up. # Yes! Node is up.
print "Setup of $pnode->{'vnode'} on $pnode->{'name'} ". print "Setup of $pnode->{'vnode'} on $pnode->{'name'} ".
" succeeded\n"; " succeeded\n";
Log(STATUSLOG(libplabmon::getPLCName()), Log(STATUSLOG($plcname),
"$self->{'NAME'}, $pnode->{'name'}, ". "$self->{'NAME'}, $pnode->{'name'}, ".
"setup, success, node came up successfully."); "setup, success, node came up successfully.");
$self->nodesetupcomplete($pnode); $self->nodesetupcomplete($pnode);
......
...@@ -54,13 +54,16 @@ my $PLABDOWN_EID = PLABDOWN_EID(); ...@@ -54,13 +54,16 @@ my $PLABDOWN_EID = PLABDOWN_EID();
my $PLABTESTING_PID = PLABTESTING_PID(); my $PLABTESTING_PID = PLABTESTING_PID();
my $PLABTESTING_EID = PLABTESTING_EID(); my $PLABTESTING_EID = PLABTESTING_EID();
my $plcname = '';
sub new($$$$$) { sub new($$$$$) {
# The next two lines are some voodoo taken from perltoot(1) # The next two lines are some voodoo taken from perltoot(1)
my $proto = shift; my $proto = shift;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
my ($poolname, $poolpid, $pooleid, $chpid2pool) = @_; my ($plcid, $poolname, $poolpid, $pooleid, $chpid2pool) = @_;
$plcname = $plcid;
# #
# Create the actual object # Create the actual object
...@@ -77,11 +80,9 @@ sub new($$$$$) { ...@@ -77,11 +80,9 @@ sub new($$$$$) {
# Clean up anything left behind by a terminated monitor # Clean up anything left behind by a terminated monitor
# XXX: this is kind of hacky, but it works. # XXX: this is kind of hacky, but it works.
# #
# NOTE: we grab all the nodes for this plc, OR any vnodes in this
# experiment that don't have entries in the plab_slice_nodes table. # figure out
# This presents a nice race, but we don't have a great way to solve
# right now.
my $plcname = libplabmon::getPLCName();
my @vnodes = (); my @vnodes = ();
my $qres = DBQueryFatal("select r.node_id" . my $qres = DBQueryFatal("select r.node_id" .
" from reserved as r" . " from reserved as r" .
...@@ -89,10 +90,12 @@ sub new($$$$$) { ...@@ -89,10 +90,12 @@ sub new($$$$$) {
" on r.node_id=psn.node_id" . " on r.node_id=psn.node_id" .
" left join plab_plc_info as ppi" . " left join plab_plc_info as ppi" .
" on psn.plc_idx=ppi.plc_idx" . " on psn.plc_idx=ppi.plc_idx" .
" left join nodes as n" .
" on r.node_id=n.node_id" .
" where r.pid='$PLABTESTING_PID'" . " where r.pid='$PLABTESTING_PID'" .
" and r.eid='$PLABTESTING_EID'" . " and r.eid='$PLABTESTING_EID'" .
" and (ppi.plc_name='$plcname'" . " and ppi.plc_name='$plcname'" .
" or ppi.plc_name is NULL)"); " and n.type=ppi.node_type");
if ($qres->num_rows()) { if ($qres->num_rows()) {
while (my @row = $qres->fetchrow_array()) { while (my @row = $qres->fetchrow_array()) {
my $vnodename = $row[0]; my $vnodename = $row[0];
...@@ -100,7 +103,9 @@ sub new($$$$$) { ...@@ -100,7 +103,9 @@ sub new($$$$$) {
} }
} }
if (@vnodes) { if (@vnodes) {
system("$VNODE_SETUP -f -k -n 100 $PLABTESTING_PID $PLABTESTING_EID"); my $nodelist = join(" ",@vnodes);
system("$VNODE_SETUP -f -k -n 100" .
" $PLABTESTING_PID $PLABTESTING_EID $nodelist");
Node::DeleteVnodes(@vnodes); Node::DeleteVnodes(@vnodes);
} }
......
...@@ -98,7 +98,7 @@ if (scalar(@ARGV) == 1) { ...@@ -98,7 +98,7 @@ if (scalar(@ARGV) == 1) {
$plcname = shift(@ARGV); $plcname = shift(@ARGV);
# XXX need to escape this better # XXX need to escape this better
if ($plcname =~ /\'/) { if (!($plcname =~ /^[\w\d\-]+$/)) {
print STDERR "plcname has illegal characters: $plcname\n"; print STDERR "plcname has illegal characters: $plcname\n";
usage(); usage();
} }
...@@ -112,9 +112,6 @@ if (scalar(@ARGV) == 1) { ...@@ -112,9 +112,6 @@ if (scalar(@ARGV) == 1) {
} }
($plcname,$plctype) = $qres->fetchrow_array(); ($plcname,$plctype) = $qres->fetchrow_array();
# tell other libplabmon users, sigh
libplabmon::setPLCName($plcname);
} }
else { else {
print STDERR "Must supply plcname argument!\n"; print STDERR "Must supply plcname argument!\n";
...@@ -177,11 +174,13 @@ OpenLog(STATUSLOG($plcname), STATUSLOGPATH($plcname)) ...@@ -177,11 +174,13 @@ OpenLog(STATUSLOG($plcname), STATUSLOGPATH($plcname))
# #
# Create the node pools. # Create the node pools.
# #
my $badpool = plabmon_badpool->new("bad", my $badpool = plabmon_badpool->new($plcname,
"bad",
$PLABDOWN_PID, $PLABDOWN_PID,
$PLABDOWN_EID, $PLABDOWN_EID,
\%chpid2pool); \%chpid2pool);
my $goodpool = plabmon_goodpool->new("good", my $goodpool = plabmon_goodpool->new($plcname,
"good",
$PLABHOLDING_PID, $PLABHOLDING_PID,
$PLABHOLDING_EID, $PLABHOLDING_EID,
\%chpid2pool); \%chpid2pool);
......
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