All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

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

Add a link to download a bundle of all logfiles.

Change the genihistory page to point to the slice page for active
slices and the log listing for terminated slices.
parent b62b142f
......@@ -40,9 +40,10 @@ sub usage()
"Spew a logfile to stdout, as for the web interface\n");
exit(-1);
}
my $optlist = "wi:a";
my $optlist = "wi:an";
my $fromweb = 0;
my $anon = 0;
my $nowait = 0;
#
# Configure variables
......@@ -86,6 +87,9 @@ if (defined($options{"w"})) {
if (defined($options{"a"})) {
$anon = 1;
}
if (defined($options{"n"})) {
$nowait = 1;
}
if (defined($options{"i"})) {
$logfile = Logfile->Lookup($options{"i"});
if (! $logfile) {
......@@ -139,7 +143,7 @@ STDOUT->autoflush(1);
# if the file is closed do it the quick way. No locking, so this could
# mess up sometimes.
#
if (!$isopen) {
if (!$isopen || $nowait) {
if ($logfile->MetadataList()) {
foreach my $ref (@{ $logfile->MetadataList() }) {
my ($key,$val) = @{$ref};
......
<?php
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -99,30 +99,30 @@ if (1) {
if (!preg_match("/^\w+\-\w+\-\w+\-\w+\-\w+$/", $slice_uuid)) {
USERERROR("Invalid slice uuid", 1);
}
$clause = "and slice_uuid='$slice_uuid' ";
$clause = "and a.slice_uuid='$slice_uuid' ";
}
else {
if ($myindex) {
$clause = "and idx<$myindex ";
$clause = "and a.idx<$myindex ";
}
if (isset($search) && isset($searchfor)) {
$safe_searchfor = addslashes($searchfor);
if (preg_match("/^\w+\-\w+\-\w+\-\w+\-\w+$/", $searchfor)) {
$clause = "$clause and slice_uuid='$safe_searchfor' ";
$clause = "$clause and a.slice_uuid='$safe_searchfor' ";
}
elseif (preg_match("/^urn:publicid:IDN\+[-\w\.]+\+slice\+[-\w]*$/",
$searchfor)) {
$clause = "$clause and slice_urn='$safe_searchfor' ";
$clause = "$clause and a.slice_urn='$safe_searchfor' ";
}
elseif (preg_match("/^urn:publicid:IDN\+[-\w\.]+\+user\+[-\w]*$/",
$searchfor)) {
$clause = "$clause and creator_urn='$safe_searchfor' ";
$clause = "$clause and a.creator_urn='$safe_searchfor' ";
}
elseif (strtotime($searchfor)) {
$ts = strtotime($searchfor);
$clause = "$clause and ($ts >= UNIX_TIMESTAMP(created) && ".
"(destroyed is null or $ts <= UNIX_TIMESTAMP(destroyed)))";
$clause = "$clause and ($ts >= UNIX_TIMESTAMP(a.created) && ".
"(a.destroyed is null or $ts <= UNIX_TIMESTAMP(a.destroyed)))";
}
elseif ($searchfor == $searchbox) {
# Just a press of the ch box, so dump out the CH records.
......@@ -133,9 +133,11 @@ if (1) {
}
}
$query_result =
DBQueryFatal("select * from aggregate_history ".
"where `type`='Aggregate' $clause ".
"order by idx desc limit 20",
DBQueryFatal("select a.*,s.idx as slice_idx ".
" from aggregate_history as a ".
"left join geni_slices as s on s.uuid=a.slice_uuid ".
"where a.type='Aggregate' $clause ".
"order by a.idx desc limit 20",
$dblink);
$table = array('#id' => 'aggregate',
......@@ -152,8 +154,10 @@ if (1) {
if (mysql_num_rows($query_result)) {
while ($row = mysql_fetch_array($query_result)) {
$idx = $row["idx"];
$slice_idx = $row["slice_idx"];
$uuid = $row["uuid"];
$slice_hrn = $row["slice_hrn"];
$slice_uuid = $row["slice_uuid"];
$creator_hrn = $row["creator_hrn"];
$slice_urn = $row["slice_urn"];
$creator_urn = $row["creator_urn"];
......@@ -169,9 +173,17 @@ if (1) {
if (isset($creator_urn)) {
$creator_info = "$creator_urn";
}
if ($destroyed) {
$url = "<a href='showslicelogs.php?slice_uuid=$slice_uuid'>";
}
else {
$url =
"<a href='showslice.php?slice_idx=$slice_idx&showtype=cm'>";
}
$url .= "$slice_info</a>";
$tablerow = array("idx" => $idx,
"hrn" => $slice_info,
"hrn" => $url,
"creator" => $creator_info,
"created" => $created,
"destroyed" => $destroyed);
......@@ -229,8 +241,6 @@ if (1) {
}
}
#
# Standard Testbed Footer
#
......
<?php
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -36,7 +36,7 @@ $isadmin = ISADMIN();
#
# Verify Page Arguments.
#
$reqargs = RequiredPageArguments("slice_idx", PAGEARG_INTEGER);
$reqargs = RequiredPageArguments("slice_idx", PAGEARG_INTEGER);
$optargs = OptionalPageArguments("showtype", PAGEARG_STRING);
if (!isset($showtype)) {
......@@ -177,6 +177,50 @@ foreach ($popups as $i => $popup) {
echo "$popup\n";
}
#
# Find all logs associated with this slice.
#
$query_result =
DBQueryFatal("select m.logidx,l.logid,l.date_created,m2.metaval ".
" from logfile_metadata as m ".
"left join logfiles as l on l.logidx=m.logidx ".
"left join logfile_metadata as m2 on ".
" m2.logidx=m.logidx and m2.metakey='Method' ".
"where m.metakey='slice_idx' and m.metaval='$slice_idx' ".
"order by l.date_created asc");
if ($query_result && mysql_num_rows($query_result)) {
$table = array('#id' => 'logfiles',
'#title' => "Log Files",
'#headings' => array("idx" => "ID",
"method" => "Op",
"created" => "Created",
"log" => "Link"));
$rows = array();
$img = "<img border='0' src='greenball.gif' />";
while ($row = mysql_fetch_array($query_result)) {
$logidx = $row["logidx"];
$logid = $row["logid"];
$op = $row["metaval"];
$date = $row["date_created"];
$url = CreateURL("spewlogfile", "logfile", $logid);
$row = array("idx" => $logidx,
"method" => $op,
"created" => $date,
"log" => "<a href='$url'>$img</a>",
);
$rows[] = $row;
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
echo "<center>
<a href='showslicelogs.php?slice_idx=$slice_idx&download=1'>
Download All Logs</a></center>";
}
#
# Standard Testbed Footer
#
......
<?php
#
# Copyright (c) 2000-2013 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/>.
#
# }}}
#
include("defs.php3");
include_once("geni_defs.php");
include("table_defs.php");
#
#
# Only known and logged in users allowed.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify Page Arguments.
#
$optargs = OptionalPageArguments("slice_idx", PAGEARG_INTEGER,
"slice_uuid", PAGEARG_STRING,
"download", PAGEARG_BOOLEAN);
#
# Standard Testbed Header
#
if (!$download) {
PAGEHEADER("Geni Slice Logs");
}
if (! ($isadmin || STUDLY())) {
USERERROR("You do not have permission to view Geni slices!", 1);
}
if (! (isset($slice_idx) || isset($slice_uuid))) {
PAGEARGERROR("Must provide a slice idx or UUID");
}
$whereclause = (isset($slice_idx) ?
"where m.metakey='slice_idx' and m.metaval='$slice_idx'" :
"where m.metakey='slice_uuid' and m.metaval='$slice_uuid'");
$urlarg = (isset($slice_idx) ?
"slice_idx=$slice_idx" : "slice_uuid=$slice_uuid");
#
# Find all logs associated with this slice.
#
$query_result =
DBQueryFatal("select m.logidx,l.logid,l.date_created,m2.metaval ".
" from logfile_metadata as m ".
"left join logfiles as l on l.logidx=m.logidx ".
"left join logfile_metadata as m2 on ".
" m2.logidx=m.logidx and m2.metakey='Method' ".
"$whereclause ".
"order by l.date_created asc");
if ($query_result && mysql_num_rows($query_result)) {
if ($download) {
header("Content-Type: text/plain");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();
while ($row = mysql_fetch_array($query_result)) {
$logid = $row["logid"];
$logidx = $row["logidx"];
if ($fp =
popen("$TBSUEXEC_PATH $uid nobody ".
"spewlogfile -w -i $logid", "r")) {
while (!feof($fp)) {
$string = fgets($fp, 1024);
echo "$string";
}
flush();
pclose($fp);
$fp = 0;
}
}
return;
}
$table = array('#id' => 'logfiles',
'#title' => "Log Files",
'#headings' => array("idx" => "ID",
"method" => "Op",
"created" => "When",
"log" => "Link"));
$rows = array();
$img = "<img border='0' src='greenball.gif' />";
while ($row = mysql_fetch_array($query_result)) {
$logidx = $row["logidx"];
$logid = $row["logid"];
$op = $row["metaval"];
$date = $row["date_created"];
$url = CreateURL("spewlogfile", "logfile", $logid);
$row = array("idx" => $logidx,
"method" => $op,
"created" => $date,
"log" => "<a href='$url'>$img</a>",
);
$rows[] = $row;
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
echo "<center>
<a href='showslicelogs.php?${urlarg}&download=1'>
Download All Logs</a></center>";
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
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