showslicepub.php 4.21 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# 
# {{{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");

#
29
# Get current user.
30
#
31
$this_user = CheckLogin($check_status);
32 33

#
34
# Public info, if you know the public token for the slice. 
35
#
36
$reqargs = RequiredPageArguments("publicid",  PAGEARG_STRING);
37 38 39 40 41 42 43

$slice = GeniSlice::LookupByPublicID("cm", $publicid);
if (!$slice) {
    USERERROR("No such slice $publicid", 1);
}
$slice_idx = $slice->idx();

44 45 46 47 48 49 50 51 52 53 54 55 56 57
#
# Send admins to the non-public page.
#
if (ISADMIN()) {
    header("Location: ".
           "$TBBASE/showslice.php?slice_idx=${slice_idx}&showtype=cm");
    return;
}

#
# Standard Testbed Header
#
PAGEHEADER("Geni Slice");

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
function GeneratePopupDiv($id, $text) {
    return "<div id=\"$id\" ".
	"style='display:none;width:700;height:400;overflow:auto;'>\n" .
	"$text\n".
	"</div>\n";
}
$manifestidx = 0;

# The table attributes:
$table = array('#id'	   => 'form1',
	       '#title'    => "Slice $slice_idx");
$rows = array();
$popups = array();

$rows[] = array("idx"      => $slice->idx());
$rows[] = array("hrn"      => $slice->hrn());
$urn = $slice->urn();
if ($urn) {
    $rows[] = array("urn"      => $slice->urn());
}
$rows[] = array("uuid"     => $slice->uuid());
$rows[] = array("created"  => $slice->created());
$rows[] = array("expires"  => $slice->expires());
if ($slice->locked()) {
    $rows[] = array("locked"  => $slice->locked());
}
if (($manifest = $slice->GetManifest())) {
    $popups[] = GeneratePopupDiv("manifest$manifestidx", $manifest);
    $rows[] = array("manifest" =>
		    "<a href='#' title='' ".
		    "onclick='PopUpWindowFromDiv(\"manifest$manifestidx\");'".
		    ">manifest</a>\n");
    $manifestidx++;
}

Leigh Stoller's avatar
Leigh Stoller committed
93
$geniuser = GeniUser::Lookup("cm", $slice->creator_uuid());
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
if ($geniuser) {
    $rows[] = array("Creator" => $geniuser->urn());
}
else {
    $user = User::LookupByUUID($slice->creator_uuid());
    if ($user) {
	$rows[] = array("Creator" => $user->uid());
    }
}

list ($html, $button) = TableRender($table, $rows);
echo $html;

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
# 
PAGEFOOTER();
?>