Commit 6b407cd1 authored by Leigh B Stoller's avatar Leigh B Stoller

Make sure that a sliver that has been stopped (power

down mode) is powered back on when starting or
deleting the sliver.
parent 8d6c36e9
......@@ -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();
}
......
......@@ -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 {
......
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