showslice.php 3.96 KB
Newer Older
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# All rights reserved.
#
include("defs.php3");
include_once("geni_defs.php");
include("table_defs.php");
include_once('JSON.php');

#
#
# Only known and logged in users allowed.
#
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();

#
# Verify Page Arguments.
#
$reqargs = RequiredPageArguments("slice_idx",   PAGEARG_INTEGER);
$optargs = OptionalPageArguments("showtype",   PAGEARG_STRING);

if (!isset($showtype)) {
    $showtype='sa';
}

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

35
if (! ($isadmin || STUDLY())) {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    USERERROR("You do not have permission to view Geni slices!", 1);
}

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

$slice = GeniSlice::Lookup($showtype, $slice_idx);
if (!$slice) {
    USERERROR("No such slice $slice_idx", 1);
}

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

$rows[] = array("idx"      => $slice->idx());
$rows[] = array("hrn"      => $slice->hrn());
55 56 57 58
$urn = $slice->urn();
if ($urn) {
    $rows[] = array("urn"      => $slice->urn());
}
59 60 61
$rows[] = array("uuid"     => $slice->uuid());
$rows[] = array("created"  => $slice->created());
$rows[] = array("expires"  => $slice->expires());
62 63 64
if ($slice->locked()) {
    $rows[] = array("locked"  => $slice->locked());
}
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
if (($manifest = $slice->GetManifest())) {
    $json = new Services_JSON();
    $manifest = $json->encode($manifest);
    $rows[] = array("manifest" =>
		    "<a href='#' title='' ".
		    "onclick='PopUpWindow($manifest);'>".
		    "Click to View</a>");
}

$experiment = Experiment::LookupByUUID($slice->uuid());
if ($experiment) {
    $eid = $experiment->eid();
    $exptidx = $experiment->idx();
    $url = CreateURL("showexp", $experiment);
    $rows[] = array("Experiment"  => "<a href='$url'>$eid ($exptidx)</a>");
}

$geniuser = GeniUser::Lookup($showtype, $slice->creator_uuid());
if ($geniuser) {
84
    $rows[] = array("Creator" => $geniuser->urn());
85 86 87 88
}
else {
    $user = User::LookupByUUID($slice->creator_uuid());
    if ($user) {
89 90
	$url = CreateURL("showuser", $user);
	$rows[] = array("Creator" => "<a href='$url'>". $user->uid() ."</a>");
91 92 93
    }
}

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
if ($showtype != "sa") {
    $saslice = GeniSlice::Lookup("sa", $slice->uuid());
    if ($saslice) {
	$saidx = $saslice->idx();
	$url   = CreateURL("showslice", "slice_idx", $saidx, "showtype", "sa");

	$rows[] = array("SA Slice" => "<a href='$url'>$saidx</a>");
    }
}
if ($showtype != "cm") {
    $cmslice = GeniSlice::Lookup("cm", $slice->uuid());
    if ($cmslice) {
	$cmidx = $cmslice->idx();
	$url   = CreateURL("showslice", "slice_idx", $cmidx, "showtype", "cm");

	$rows[] = array("CM Slice" => "<a href='$url'>$cmidx</a>");
    }
}
112 113 114 115 116 117 118

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

$clientslivers = ClientSliver::SliverList($slice);
if ($clientslivers && count($clientslivers)) {
    $table = array('#id'	   => 'clientslivers',
119 120 121 122 123 124
		   '#title'        => "Client Slivers",
		   '#headings'     => array("idx"      => "ID",
					    "urn"      => "URN",
					    "manager"  => "Manager URN",
					    "created"  => "Created",
					    "manifest" => "Manifest"));
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
    $rows = array();

    foreach ($clientslivers as $clientsliver) {
	$row = array("idx"      => $clientsliver->idx(),
		     "urn"      => $clientsliver->urn(),
		     "manager"  => $clientsliver->manager_urn(),
		     "created"  => $clientsliver->created());

	if ($clientsliver->manifest()) {
	    $json = new Services_JSON();
	    $manifest = $json->encode($clientsliver->manifest());
	    
	    $row["manifest"] =
		"<a href='#' title='' ".
		"onclick='PopUpWindow($manifest);'>".
		"Manifest</a>";
	}
142 143 144
	else {
	    $row["manifest"] = "Unknown";
	}
145 146 147 148 149 150 151 152 153 154 155 156 157
	$rows[] = $row;
    }

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

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