Commit ea3390e2 authored by Leigh B Stoller's avatar Leigh B Stoller

Record of an instance is terminated vs expired, in the history table.

parent a925a0db
......@@ -29,10 +29,15 @@ use English;
use Data::Dumper;
use POSIX qw(tmpnam);
use Exporter;
use vars qw(@ISA @EXPORT $AUTOLOAD);
use vars qw(@ISA @EXPORT $AUTOLOAD
$RECORDHISTORY_TERMINATED $RECORDHISTORY_EXPIRED);
@ISA = "Exporter";
@EXPORT = qw ( );
# RecordHistory flags.
$RECORDHISTORY_TERMINATED = 0x00;
$RECORDHISTORY_EXPIRED = 0x01;
@EXPORT = qw($RECORDHISTORY_TERMINATED $RECORDHISTORY_EXPIRED);
# Must come after package declaration!
use EmulabConstants;
......@@ -469,10 +474,12 @@ sub Profile($)
# Record a history entry.
# We do this when the instance is terminated.
#
sub RecordHistory($)
sub RecordHistory($$)
{
my ($self) = @_;
my ($self, $flags) = @_;
my $uuid = $self->uuid();
my $expired = ($flags ? 1 : 0);
DBQueryWarn("replace into apt_instance_aggregate_history ".
"select * from apt_instance_aggregates where uuid='$uuid'")
......@@ -481,7 +488,7 @@ sub RecordHistory($)
DBQueryWarn("replace into apt_instance_history ".
"select uuid,name,profile_id,profile_version,slice_uuid, ".
" creator,creator_idx,creator_uuid,pid,pid_idx, ".
" aggregate_urn,public_url,created,now(),0, ".
" aggregate_urn,public_url,created,now(),$expired, ".
" extension_count,extension_days, ".
" physnode_count,virtnode_count, ".
" servername,rspec,params,manifest ".
......
......@@ -697,6 +697,17 @@ sub DoTerminate()
{
my $errmsg;
my $logfile;
my $expired = $RECORDHISTORY_TERMINATED;
if (@ARGV) {
my $arg = shift(@ARGV);
if ($arg eq "-e") {
$expired = $RECORDHISTORY_EXPIRED;
}
else {
usage();
}
}
my $slice = $instance->GetGeniSlice();
if (!defined($slice)) {
......@@ -793,7 +804,7 @@ sub DoTerminate()
}
$slice->Delete();
$instance->RecordHistory();
$instance->RecordHistory($expired);
killit:
$instance->Delete();
unlink($logfile)
......@@ -1057,7 +1068,7 @@ sub DoRefresh()
$slice->UnLock();
exit(0);
killit:
$instance->RecordHistory();
$instance->RecordHistory($RECORDHISTORY_TERMINATED);
$instance->Delete();
exit(0);
bad:
......@@ -1210,7 +1221,7 @@ sub DoRebootOrReload($)
StartMonitor();
exit(0);
killit:
$instance->RecordHistory();
$instance->RecordHistory($RECORDHISTORY_TERMINATED);
$instance->Delete();
exit(0);
bad:
......
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