genislices.php 2.86 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2012 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
# 
# {{{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/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#
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("showtype",   PAGEARG_STRING);
$showtypes = array();

if (!isset($showtype)) {
    $showtypes[] = "cm";
    $showtypes[] = "sa";
    $showtypes[] = "ch";
}
else {
    if (! ($showtype == "sa"|| $showtype == "cm" || $showtype == "ch")) {
	USERERROR("Improper argument: showtype=$showtype", 1);
    }
    $showtypes[] = $showtype;
}

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

59
if (! ($isadmin || STUDLY())) {
60 61 62 63 64 65 66 67 68 69 70 71 72
    USERERROR("You do not have permission to view Geni slice list!", 1);
}

foreach ($showtypes as $type) {
    $slicelist = GeniSlice::AllSlices($type);
    $which = ($type == "cm" ? "Component Manager" :
	      ($type == "sa" ? "Slice Authority" : "Clearing House"));

    if (!$slicelist || !count($slicelist))
	continue;

    # The form attributes:
    $table = array('#id'       => $type,
73 74 75 76 77 78 79
		   '#title'    => $which,
		   '#sortable' => 1,
		   '#headings' => array("idx"          => "ID",
					"hrn"          => "HRN",
					"created"      => "Created",
					"expires"      => "Expires"));

80 81 82 83 84
    $rows = array();

    foreach ($slicelist as $slice) {
	$slice_idx  = $slice->idx();
	$slice_hrn  = $slice->hrn();
85 86
	$created    = $slice->created();
	$expires    = $slice->expires();
87

88 89 90 91 92 93 94 95 96 97
	$url = CreateURL("showslice", "showtype", $type,
			 "slice_idx", $slice_idx);
	$href = "<a href='$url'>$slice_hrn</a>";

	$experiment = Experiment::LookupByUUID($slice->uuid());
	if ($experiment) {
	    $eid     = $experiment->eid();
	    $expurl  = CreateURL("showexp", $experiment);
	    $href    = "$href (<a href='$expurl'>$eid</a>)";
	}
98 99 100 101
	$rows[$slice_idx] = array("idx"       => $slice_idx,
				  "hrn"       => $href,
				  "created"   => $created,
				  "expires"   => $expires);
102 103 104 105 106 107 108 109 110 111 112
    }
    list ($html, $button) = TableRender($table, $rows);
    echo $html;
}

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>