Commit 27aed939 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add state and SetState() for new sliver state tracking. Eventually

replace the "status" field, but this will allow me to work in parallel
on version two of the API.
parent e5b40541
......@@ -201,6 +201,7 @@ sub created($) { return field($_[0], "created"); }
sub credential_idx($) { return field($_[0], "credential_idx"); }
sub aggregate_idx($) { return field($_[0], "aggregate_idx"); }
sub status($) { return field($_[0], "status"); }
sub state($) { return field($_[0], "state"); }
sub cert($) { return $_[0]->{'CERTIFICATE'}->cert(); }
sub GetCertificate($) { return $_[0]->{'CERTIFICATE'}; }
......@@ -480,6 +481,27 @@ sub SetStatus($$)
return 0;
}
#
# Set the state for the aggregate
#
sub SetState($$)
{
my ($self, $state) = @_;
return undef
if (! ref($self));
my $idx = $self->idx();
return -1
if (!DBQueryWarn("update geni_aggregates set ".
" state='$state' ".
"where idx='$idx'"));
$self->{'AGGREGATE'}->{'state'} = $state;
return 0;
}
#
# Get the slice for the aggregate.
#
......
......@@ -230,6 +230,7 @@ sub component_uuid($) { return field($_[0], "component_uuid"); }
sub aggregate_uuid($) { return field($_[0], "aggregate_uuid"); }
sub rspec_string($) { return field($_[0], "rspec_string"); }
sub status($) { return field($_[0], "status"); }
sub state($) { return field($_[0], "state"); }
sub cert($) { return $_[0]->{'CERTIFICATE'}->cert(); }
sub GetCertificate($) { return $_[0]->{'CERTIFICATE'}; }
sub rspec($) { return $_[0]->{'RSPEC'}; }
......@@ -362,6 +363,27 @@ sub SetStatus($$)
return 0;
}
#
# Set the state for the sliver.
#
sub SetState($$)
{
my ($self, $state) = @_;
return undef
if (! ref($self));
my $idx = $self->idx();
return -1
if (!DBQueryWarn("update geni_slivers set ".
" state='$state' ".
"where idx='$idx'"));
$self->{'SLIVER'}->{'state'} = $state;
return 0;
}
#
# Get the experiment for the slice this sliver belongs to.
#
......@@ -729,6 +751,9 @@ sub UnProvision($;$)
if (scalar(@vnodes) > 1 || $nophysfree) {
system("$NFREE -q $pid $eid $node_id");
# Unincorporate the node. Bogus, needs fixing.
$pnode->ModifyReservation({"genisliver_idx" => 0})
if (! ($pnode->sharing_mode() || scalar(@vnodes) > 1));
}
else {
system("$NFREE -x -q $pid $eid $pnode_id");
......@@ -736,8 +761,11 @@ sub UnProvision($;$)
}
}
else {
goto skip
if ($nophysfree);
if ($nophysfree) {
# Unincorporate the node. Bogus, needs fixing.
$node->ModifyReservation({"genisliver_idx" => 0});
goto skip;
}
system("$NFREE -q $pid $eid $node_id");
}
if ($?) {
......
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