Commit f0f6d574 authored by Leigh Stoller's avatar Leigh Stoller

Small set of changes to deal with powering off only radio gear at the

Mothership, when doing a power panic button.
parent d34f6d3d
......@@ -3402,9 +3402,9 @@ sub Lockdown($$$)
#
# Panic
#
sub Panic($$$)
sub Panic($$$$)
{
my ($self, $clear, $poweroff) = @_;
my ($self, $clear, $poweroff, $radiosonly) = @_;
my $authority = $self->GetGeniAuthority();
my $slice = $self->instance()->GetGeniSlice();
my $context = APT_Geni::GeniContext();
......
......@@ -3326,9 +3326,10 @@ sub DoPanic()
my $response;
my $logfile;
my $optlist = "Lpf";
my $optlist = "LpfR";
my $takelock = 0;
my $poweroff = 0;
my $radiosonly = 0;
my $foreground = 0;
my %options = ();
......@@ -3340,6 +3341,9 @@ sub DoPanic()
}
if (defined($options{"p"})) {
$poweroff = 1;
if (defined($options{"R"})) {
$radiosonly = 1;
}
}
if (defined($options{"f"})) {
$foreground = 1;
......@@ -3443,7 +3447,8 @@ sub DoPanic()
my $coderef = sub {
my ($sliver) = @_;
return $sliver->Panic(($setclr eq "clear" ? 1 : 0), $poweroff);
return $sliver->Panic(($setclr eq "clear" ? 1 : 0),
$poweroff, $radiosonly);
};
# Invoke on all clusters
......
......@@ -186,15 +186,17 @@ while (my ($uuid) = $query_result->fetchrow_array()) {
next;
}
my @nodelist = $experiment->NodeList(0);
my $bad = 0;
my $killme = 0;
foreach my $node (@nodelist) {
my $nodetype = $node->NodeTypeInfo();
if ($nodetype && $nodetype->GetAttribute("panicpoweroff")) {
$bad = 0;
my $val = undef;
if ($node->NodeAttribute("panicpoweroff", \$val) == 0 &&
defined($val) && $val) {
$killme = 1;
last;
}
}
if ($bad) {
if ($killme) {
push(@killme, $instance);
last;
}
......@@ -248,7 +250,7 @@ while (@killme) {
next;
}
print "Setting quarantine mode (with power off) on $instance\n";
system("$MANAGEINSTANCE panic $uuid -f -p set");
system("$MANAGEINSTANCE panic $uuid -f -p -R set");
if ($?) {
print "Will try again later\n";
push(@killme, $instance);
......
......@@ -79,6 +79,7 @@ my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $TBAPPROVAL = "@TBAPPROVALEMAIL@";
my $TBAUDIT = "@TBAUDITEMAIL@";
my $MAINSITE = @TBMAINSITE@;
my $BOSSNODE = "@BOSSNODE@";
my $OURDOMAIN = "@OURDOMAIN@";
my $PGENIDOMAIN = "@PROTOGENI_DOMAIN@";
......@@ -5931,6 +5932,7 @@ sub Panic($)
my $slice_urn = $argref->{'slice_urn'};
my $clear = $argref->{'clear'};
my $poweroff = $argref->{'poweroff'};
my $radiosonly = $argref->{'radiosonly'};
my $credentials = $argref->{'credentials'};
my $forked = 0;
......@@ -6057,6 +6059,7 @@ sub Panic($)
my $pid = $experiment->pid();
my $eid = $experiment->eid();
my $command = "$WAP $PANIC -l " . ($poweroff ? "3" : "1") . " " .
($MAINSITE && $radiosonly ? "-R" : "") . " " .
($clear ? "-r " : "") . "$pid $eid";
GeniUtil::FlipToElabMan();
......
......@@ -38,6 +38,7 @@ sub usage()
"-l level - Level 1; reboot nodes into the admin MFS\n".
" - Level 2; disable the control network\n".
" - Level 3; power off all nodes\n".
"-R - With level 3, power off only the radio equipment\n".
"-r - Reset panic state (admin people only)\n".
"-c - Clear panic state but do not do anything else\n".
"-w - From web interface, create a log file.\n".
......@@ -45,11 +46,12 @@ sub usage()
"<eid> - The experiment name (id)\n");
exit(-1);
}
my $optlist = "rl:wc";
my $optlist = "rl:wcR";
my $reset = 0;
my $clear = 0;
my $level = 1;
my $dolog = 0;
my $radiosonly = 0;
sub fatal($);
sub DoIt();
......@@ -133,6 +135,9 @@ if (defined($options{"r"})) {
if (defined($options{"w"})) {
$dolog = 1;
}
if (defined($options{"R"})) {
$radiosonly = 1;
}
if (defined($options{"l"})) {
$level = $options{"l"};
usage()
......@@ -315,13 +320,25 @@ sub PowerMode()
my @failures = ();
# Need a list of nodes, going to call power individually.
my @nodes = $experiment->NodeList(1, 0);
my @nodes = $experiment->NodeList(0, 0);
if (!@nodes) {
$experiment->Unlock();
fatal("Could not get node list for experiment");
}
foreach my $node_id (@nodes) {
# Tell power to send an event.
foreach my $node (@nodes) {
my $node_id = $node->node_id();
#
# If radiosonly, then look for special node attribute.
# Skip all other nodes. (Powder Panic Button).
#
if ($radiosonly) {
my $val = undef;
next
if (! ($node->NodeAttribute("panicpoweroff", \$val) == 0 &&
defined($val) && $val));
}
system("$POWER " . ($reset ? "on" : "off") . " $node_id");
if ($?) {
push(@failures, $node_id);
......
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