Commit 956305ab authored by Leigh B Stoller's avatar Leigh B Stoller

Record the servername in the apt instance and history tables, so that we

can tell which interface (APT or CloudLab) was used to create an instance.
Don't want to have to go back and parse email.
parent 8148afa1
......@@ -93,6 +93,8 @@ AUTOLOAD {
carp("No such slot '$name' field in class $type");
return undef;
}
sub isAPT($) { return $_[0]->servername() =~ /aptlab/ ? 1 : 0; }
sub isCloud($) { return $_[0]->servername() =~ /cloudlab/ ? 1 : 0; }
# Break circular reference someplace to avoid exit errors.
sub DESTROY {
......@@ -299,7 +301,7 @@ sub RecordHistory($)
DBQueryWarn("replace into apt_instance_history ".
"select uuid,profile_id,profile_version,slice_uuid, ".
" creator,creator_idx,creator_uuid,aggregate_urn, ".
" created,now() ".
" created,now(),servername ".
" from apt_instances where uuid='$uuid'")
or return -1;
......
......@@ -472,11 +472,12 @@ if ($geniuser->GetKeyBundle(\@sshkeys, 1) < 0 || !@sshkeys) {
my $slice_id = $user_uid . "-QV" . TBGetUniqueIndex('next_quickvm', 1);
my $slice_urn = GeniHRN::Generate($OURDOMAIN, "slice", $slice_id);
my $slice_hrn = "${PGENIDOMAIN}.${slice_id}";
my $SERVER_NAME = (exists($ENV{"SERVER_NAME"}) ? $ENV{"SERVER_NAME"} : "");
print STDERR "\n";
print STDERR "$user_urn\n";
print STDERR "$slice_urn\n";
print STDERR $ENV{"SERVER_NAME"} . "\n" if (exists($ENV{"SERVER_NAME"}));
print STDERR "$SERVER_NAME\n";
print STDERR "\n";
print STDERR "$rspecstr\n";
......@@ -539,7 +540,8 @@ my $instance = APT_Instance->Create({'uuid' => $quickvm_uuid,
'creator_idx' => $geniuser->idx(),
'creator_uuid' => $geniuser->uuid(),
'aggregate_urn'=> $CMURN,
'status' => "created"});
'status' => "created",
'servername' => $SERVER_NAME});
if (!defined($instance)) {
$slice->Delete();
fatal("Could not create instance record for $quickvm_uuid");
......
......@@ -55,7 +55,7 @@ CREATE TABLE `active_checkups` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `apt_instances`
-- Table structure for table `apt_instance_history`
--
DROP TABLE IF EXISTS `apt_instance_history`;
......@@ -70,6 +70,7 @@ CREATE TABLE `apt_instance_history` (
`aggregate_urn` varchar(128) default NULL,
`created` datetime default NULL,
`destroyed` datetime default NULL,
`servername` tinytext,
PRIMARY KEY (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -90,6 +91,7 @@ CREATE TABLE `apt_instances` (
`created` datetime default NULL,
`status` varchar(32) default NULL,
`extension_code` varchar(32) default NULL,
`servername` tinytext,
`manifest` mediumtext,
PRIMARY KEY (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......
#
#
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("apt_instances", "servername")) {
DBQueryFatal("ALTER TABLE apt_instances ADD ".
" `servername` tinytext after extension_code");
DBQueryFatal("update apt_instances set servername='www.aptlab.net'");
}
if (!DBSlotExists("apt_instance_history", "servername")) {
DBQueryFatal("ALTER TABLE apt_instance_history ADD ".
" `servername` tinytext");
DBQueryFatal("update apt_instance_history ".
"set servername='www.aptlab.net'");
}
return 0;
}
# Local Variables:
# mode:perl
# End:
......@@ -64,6 +64,13 @@ class Instance
function profile_version() { return $this->field('profile_version'); }
function status() { return $this->field('status'); }
function manifest() { return $this->field('manifest'); }
function servername() { return $this->field('servername'); }
function IsAPT() {
return preg_match('/aptlab/', $this->servername());
}
function IsCloud() {
return preg_match('/cloudlab/', $this->servername());
}
# Hmm, how does one cause an error in a php constructor?
function IsValid() {
......@@ -209,5 +216,9 @@ class Instance
return mysql_num_rows($query_result);
}
function SendEmail($to, $subject, $msg, $headers) {
TBMAIL($to, $subject, $msg, $headers);
}
}
?>
......@@ -56,18 +56,18 @@ if ($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.aptlab.net") {
$APTHOST = "www.aptlab.net";
$WWWHOST = "www.aptlab.net";
$APTBASE = "https://www.aptlab.net";
$APTMAIL = "APT Operations <testbed-ops@aptlab.net>";
$APTMAIL = "APT Operations <aptlab-ops@aptlab.net>";
$GOOGLEUA = 'UA-42844769-3';
$TBMAILTAG = "aptlab.net";
}
elseif (0 || ($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.cloudlab.us")) {
elseif (1 || ($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.cloudlab.us")) {
$ISVSERVER = 1;
$TBAUTHDOMAIN = ".cloudlab.us";
$COOKDIEDOMAIN= "www.cloudlab.us";
$APTHOST = "www.cloudlab.us";
$WWWHOST = "www.cloudlab.us";
$APTBASE = "https://www.cloudlab.us";
$APTMAIL = "Cloud Lab Operations <testbed-ops@aptlab.net>";
$APTMAIL = "CloudLab Operations <cloudlab-ops@cloudlab.us>";
$APTTITLE = "CloudLab";
$FAVICON = "cloudlab.ico";
$APTLOGO = "cloudlogo.png";
......
......@@ -153,7 +153,7 @@ function Do_RequestExtension()
{
global $instance, $creator;
global $ajax_args;
global $TBMAIL_OPS;
global $TBMAIL_OPS, $APTMAIL;
if (!isset($ajax_args["reason"])) {
SPITAJAX_ERROR(1, "Missing reason");
......@@ -188,14 +188,15 @@ function Do_RequestExtension()
SPITAJAX_RESPONSE($new_expires);
TBMAIL($creator->email(),
"APT Extension: $uuid",
"A request to extend your APT experiment was made and ".
$instance->SendEmail($creator->email(),
"Experiment Extension: $uuid",
"A request to extend your experiment was made and ".
"granted.\n".
"Your reason was:\n\n". $reason . "\n\n".
"Your experiment will now expire at $new_expires.\n\n".
"You can request another extension tomorrow.\n",
"CC: $TBMAIL_OPS");
"From: $APTMAIL\n" .
"BCC: $TBMAIL_OPS");
}
elseif ($retval > 0) {
SPITAJAX_ERROR(1, $suexec_output);
......
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