Commit bdf25e3a authored by Leigh Stoller's avatar Leigh Stoller

Add a spew logfile to apt_instances, and show that in the UI.

Currently using it for the stitcher log, more later. Needed to
a little rearranging in spewlogfile.php3 so that I could use it
from the Cloudlab UI.
parent c0f02b11
...@@ -48,6 +48,7 @@ use GeniCredential; ...@@ -48,6 +48,7 @@ use GeniCredential;
use GeniHRN; use GeniHRN;
use GeniXML; use GeniXML;
use WebTask; use WebTask;
use Logfile;
use overload ('""' => 'Stringify'); use overload ('""' => 'Stringify');
# Configure variables # Configure variables
...@@ -304,6 +305,13 @@ sub Delete($) ...@@ -304,6 +305,13 @@ sub Delete($)
my ($self) = @_; my ($self) = @_;
my $uuid = $self->uuid(); my $uuid = $self->uuid();
if (defined($self->logfileid())) {
my $logfile = Logfile->Lookup($self->logfileid());
if (defined($logfile)) {
# purge the actual file.
$logfile->Delete(1);
}
}
foreach my $agg ($self->AggregateList()) { foreach my $agg ($self->AggregateList()) {
$agg->Delete() == 0 $agg->Delete() == 0
or return -1; or return -1;
...@@ -392,6 +400,19 @@ sub SetManifest($$) ...@@ -392,6 +400,19 @@ sub SetManifest($$)
return 0; return 0;
} }
#
# Set to use the logfile.
#
sub SetLogFile($$)
{
my ($self, $logfile) = @_;
return -1
if ($self->Update({'logfileid' => $logfile->logid()}));
return 0;
}
# #
# Set/Clear the lockdown bits. # Set/Clear the lockdown bits.
# #
......
...@@ -123,6 +123,7 @@ use Genixmlrpc; ...@@ -123,6 +123,7 @@ use Genixmlrpc;
use GeniResponse; use GeniResponse;
use GeniXML; use GeniXML;
use WebTask; use WebTask;
use Logfile;
# #
# Parse command arguments. Once we return from getopts, all that should be # Parse command arguments. Once we return from getopts, all that should be
...@@ -828,8 +829,6 @@ sub WaitForSliver($) ...@@ -828,8 +829,6 @@ sub WaitForSliver($)
if (exists($repblob->{'public_url'})) { if (exists($repblob->{'public_url'})) {
$public_url = $repblob->{'public_url'}; $public_url = $repblob->{'public_url'};
$aggobj->SetPublicURL($public_url); $aggobj->SetPublicURL($public_url);
# Temporary until web interface catches up.
$instance->SetPublicURL($public_url);
} }
if ($repblob->{'status'} eq "ready") { if ($repblob->{'status'} eq "ready") {
$ready = 1; $ready = 1;
...@@ -1157,6 +1156,20 @@ sub RunStitcher() ...@@ -1157,6 +1156,20 @@ sub RunStitcher()
print XML $rspecstr; print XML $rspecstr;
close(XML); close(XML);
#
# Use a log file for the stitcher output, so we can spew it.
# The file in the tmp dir has to exist.
#
system("/bin/cp /dev/null $stdoutfile");
my $logfile = Logfile->Create($project->GetProjectGroup(), $stdoutfile);
if (!defined($logfile)) {
print STDERR "Could not create logfile\n";
}
else {
$logfile->Open();
$instance->SetLogFile($logfile);
}
# #
# Okay, run the stitcher. Only to allocate, we will do the provisions # Okay, run the stitcher. Only to allocate, we will do the provisions
# so that we can pass the ssh keys more easily. # so that we can pass the ssh keys more easily.
...@@ -1177,6 +1190,10 @@ sub RunStitcher() ...@@ -1177,6 +1190,10 @@ sub RunStitcher()
# #
$failed = 1; $failed = 1;
} }
if (defined($logfile)) {
$logfile->Close();
$logfile->Store();
}
# #
# The stitcher puts the list of aggregates into a file, read that so # The stitcher puts the list of aggregates into a file, read that so
...@@ -1297,8 +1314,21 @@ sub RunStitcher() ...@@ -1297,8 +1314,21 @@ sub RunStitcher()
$webtask->Exited(-1); $webtask->Exited(-1);
return -1; return -1;
} }
# Web interface wants this as soon as possible.
$aggobj->SetManifest($manifest);
print "Forcing correct slice expiration\n";
my $response = $aggobj->Extend($slice->ExpirationGMT());
if (!defined($response) ||
$response->code() != GENIRESPONSE_SUCCESS) {
$aggobj->SetStatus("failed");
$webtask->output("Renew failed on $urn");
$webtask->Exited(-1);
print STDERR "Renew failed on $urn\n";
return -1;
}
print "Calling SliverStart at $urn\n"; print "Calling SliverStart at $urn\n";
my $response = $aggobj->SliverAction(\$errmsg, "start"); $response = $aggobj->SliverAction(\$errmsg, "start");
if (! defined($response)) { if (! defined($response)) {
$aggobj->SetStatus("failed"); $aggobj->SetStatus("failed");
$webtask->output($errmsg); $webtask->output($errmsg);
...@@ -1309,7 +1339,6 @@ sub RunStitcher() ...@@ -1309,7 +1339,6 @@ sub RunStitcher()
$aggobj->SetPublicURL($response->logurl()) $aggobj->SetPublicURL($response->logurl())
if (defined($response->logurl())); if (defined($response->logurl()));
$aggobj->SetStatus("provisioned"); $aggobj->SetStatus("provisioned");
$aggobj->SetManifest($manifest);
return 0; return 0;
}; };
...@@ -1338,8 +1367,8 @@ sub RunStitcher() ...@@ -1338,8 +1367,8 @@ sub RunStitcher()
goto bad; goto bad;
} }
} }
# system("/bin/rm -rf $tmpdir") system("/bin/rm -rf $tmpdir")
# if (!$debug && defined($tmpdir) && -e $tmpdir); if (!$debug && defined($tmpdir) && -e $tmpdir);
return 0; return 0;
bad: bad:
......
...@@ -37,7 +37,7 @@ $urn_mapping = ...@@ -37,7 +37,7 @@ $urn_mapping =
"urn:publicid:IDN+apt.emulab.net+authority+cm" => "APT", "urn:publicid:IDN+apt.emulab.net+authority+cm" => "APT",
"urn:publicid:IDN+emulab.net+authority+cm" => "MS", "urn:publicid:IDN+emulab.net+authority+cm" => "MS",
"urn:publicid:IDN+utahddc.geniracks.net+authority+cm" => "DDC", "urn:publicid:IDN+utahddc.geniracks.net+authority+cm" => "DDC",
"urn:publicid:IDN+stitch.geniracks.net+authority+cm" => "Stitch", "urn:publicid:IDN+stitch.geniracks.net+authority+cm" => "UStitch",
"urn:publicid:IDN+al2s.internet2.edu+authority+cm" => "AL2S"); "urn:publicid:IDN+al2s.internet2.edu+authority+cm" => "AL2S");
$freenodes_mapping = $freenodes_mapping =
...@@ -95,6 +95,7 @@ class Instance ...@@ -95,6 +95,7 @@ class Instance
function pid() { return $this->field('pid'); } function pid() { return $this->field('pid'); }
function pid_idx() { return $this->field('pid_idx'); } function pid_idx() { return $this->field('pid_idx'); }
function public_url() { return $this->field('public_url'); } function public_url() { return $this->field('public_url'); }
function logfileid() { return $this->field('logfileid'); }
function manifest() { return $this->field('manifest'); } function manifest() { return $this->field('manifest'); }
function admin_lockdown() { return $this->field('admin_lockdown'); } function admin_lockdown() { return $this->field('admin_lockdown'); }
function user_lockdown(){ return $this->field('user_lockdown'); } function user_lockdown(){ return $this->field('user_lockdown'); }
......
...@@ -361,6 +361,10 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -361,6 +361,10 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
if (_.has(json.value, "sliverurls")) { if (_.has(json.value, "sliverurls")) {
ShowSliverInfo(json.value.sliverurls); ShowSliverInfo(json.value.sliverurls);
} }
// Ditto the logfile.
if (_.has(json.value, "logfile_url")) {
ShowLogfile(json.value.logfile_url);
}
if (status == 'provisioned') { if (status == 'provisioned') {
$("#status_progress_bar").width("66%"); $("#status_progress_bar").width("66%");
...@@ -1586,5 +1590,12 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -1586,5 +1590,12 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
$("#sliverinfo_dropdown").removeClass("hidden"); $("#sliverinfo_dropdown").removeClass("hidden");
} }
function ShowLogfile(url)
{
// URLs change over time.
$("#logfile_button").attr("href", url);
$("#logfile_button").removeClass("hidden");
}
$(document).ready(initialize); $(document).ready(initialize);
}); });
<?php
#
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir("..");
include_once("defs.php3");
chdir("apt");
include("quickvm_sup.php");
chdir("..");
include("spewlogfile.php3");
?>
...@@ -87,7 +87,7 @@ function StatusSetupAjax($needmodify) ...@@ -87,7 +87,7 @@ function StatusSetupAjax($needmodify)
# #
function Do_GetInstanceStatus() function Do_GetInstanceStatus()
{ {
global $instance, $creator; global $instance, $creator, $APTBASE;
if (StatusSetupAjax(0)) { if (StatusSetupAjax(0)) {
return; return;
...@@ -96,6 +96,11 @@ function Do_GetInstanceStatus() ...@@ -96,6 +96,11 @@ function Do_GetInstanceStatus()
$blob["status"] = $instance->status(); $blob["status"] = $instance->status();
$blob["sliverstatus"] = array(); $blob["sliverstatus"] = array();
$blob["sliverurls"] = array(); $blob["sliverurls"] = array();
if ($instance->logfileid()) {
$blob["logfile_url"] =
"$APTBASE/spewlogfile.php?logfile=" . $instance->logfileid();
}
# #
# If we have all of our manifests, the client can request them # If we have all of our manifests, the client can request them
......
...@@ -87,6 +87,14 @@ ...@@ -87,6 +87,14 @@
type='button'>Go</a> type='button'>Go</a>
</div> </div>
</div> </div>
<div class='pull-left'>
<a class='hidden'
style='margin-right: 10px;'
id='logfile_button'
href='#'
target='_blank'
type='button'>Logfile</a>
</div>
<% if (isadmin) { %> <% if (isadmin) { %>
<div class='pull-left' <div class='pull-left'
data-toggle='popover' data-toggle='popover'
......
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<script src="apt/js/lib/jquery-2.0.3.min.js"></script>
<script src="apt/js/lib/underscore-min.js"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
var lastIndex = 0; var lastIndex = 0;
// The url is the same as this one with 'spewlogfile.php3' instead of // The url is the same as this one with 'spewlogfile.php3' instead of
// the current path. // the current path.
var url = 'spewlogfile.php3' + var url = window.location + '&isajax=1';
window.location.search + '&isajax=1';
// Fetch spewlogfile via AJAX call // Fetch spewlogfile via AJAX call
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
...@@ -53,8 +46,7 @@ ...@@ -53,8 +46,7 @@
xhr.send(); xhr.send();
}); });
</script> </script>
</head>
<body> <body>
<pre></pre> <pre></pre>
</body> </body>
</html>
<?php <?php
# #
# Copyright (c) 2000-2014 University of Utah and the Flux Group. # Copyright (c) 2000-2015 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# #
# }}} # }}}
# #
include("defs.php3"); include_once("defs.php3");
# #
# Get current user, but allow for anon access. # Get current user, but allow for anon access.
...@@ -55,7 +55,11 @@ if (!isset($isajax) && $logfile->isopen()) { ...@@ -55,7 +55,11 @@ if (!isset($isajax) && $logfile->isopen()) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache"); header("Pragma: no-cache");
echo "<html>\n";
echo "<script src='$TBBASE/apt/js/lib/jquery-2.0.3.min.js'></script>\n";
echo "<script src='$TBBASE/apt/js/lib/underscore-min.js'></script>\n";
readfile("fetchlogfile.html"); readfile("fetchlogfile.html");
echo "</html>\n";
return; return;
} }
......
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