Commit 3c89acf4 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add some simple web pages for displaying protogeni slices and slivers.

Got tired of looking in the DB.
parent 045e98ed
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Lets emulate register_globals=off for a while.
......@@ -33,6 +33,7 @@ $BUGDBSUPPORT = @BUGDBSUPPORT@;
$CVSSUPPORT = @CVSSUPPORT@;
$MAILMANSUPPORT = @MAILMANSUPPORT@;
$CHATSUPPORT = @CHATSUPPORT@;
$PROTOGENI = @PROTOGENI_SUPPORT@;
$ISOLATEADMINS = @ISOLATEADMINS@;
$CONTROL_NETWORK= "@CONTROL_NETWORK@";
$CONTROL_NETMASK= "@CONTROL_NETMASK@";
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2006-2008 University of Utah and the Flux Group.
* Copyright (c) 2006-2009 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
......@@ -497,3 +497,19 @@ function toggle_menu(e_list, e_arrow) {
}
return true;
}
function PopUpWindow(text)
{
var newWinHeight = 400;
var newWinWidth = 700;
var newWinTop = (screen.height-newWinHeight)/2;
var newWinLeft = (screen.width-newWinWidth)/2;
var winProps = eval('"resizable=yes,menubar=no,toolbar=no,scrollbars=yes,top=" +newWinTop+ ",left=" +newWinLeft+ ",width=" +newWinWidth+ ",height=" +newWinHeight');
myWindow = window.open('', "XML", winProps);
myWindow.document.write('<html><head><title>XML</title></head>');
myWindow.document.write('<body><xmp>' + text + '</xmp></body></html>');
myWindow.document.close();
}
......@@ -6,6 +6,7 @@
#
#
include_once("template_defs.php");
include_once("geni_defs.php");
# This class is really just a wrapper around the DB data ...
#
......@@ -108,6 +109,21 @@ class Experiment
return Experiment::Lookup($idx);
}
function LookupByUUID($uuid) {
$safe_uuid = addslashes($uuid);
$query_result =
DBQueryWarn("select idx from experiments ".
"where eid_uuid='$safe_uuid'");
if (!$query_result || !mysql_num_rows($query_result)) {
return null;
}
$row = mysql_fetch_array($query_result);
$idx = $row['idx'];
return Experiment::Lookup($idx);
}
#
# Refresh an instance by reloading from the DB.
......@@ -1063,47 +1079,37 @@ class Experiment
</tr>\n";
}
if (!$short && ISADMIN() && $this->geniflags()) {
$dbid = DBConnect("geni-cm");
$slice_hrn = null;
$user_hrn = null;
if ($dbid) {
$geni_result =
DBQueryFatal("select hrn,creator_uuid from geni_slices ".
"where uuid='$uuid'", $dbid);
if ($geni_result &&
mysql_num_rows($geni_result)) {
$genirow = mysql_fetch_array($geni_result);
$creator_uuid = $genirow["creator_uuid"];
$slice_hrn = $genirow["hrn"];
$geni_result =
DBQueryFatal("select hrn from geni_users ".
"where uuid='$creator_uuid'", $dbid);
if ($geni_result &&
mysql_num_rows($geni_result)) {
$genirow = mysql_fetch_array($geni_result);
$user_hrn = $genirow["hrn"];
}
else {
$user = User::LookupByUUID($creator_uuid);
if ($user) {
$user_hrn = $user->uid();
}
}
if (! is_null($slice_hrn)) {
echo "<tr>
<td>Geni Slice HRN: </td>
<td class=\"left\">$slice_hrn</td>
</tr>\n";
}
if (! is_null($user_hrn)) {
echo "<tr>
<td>Geni User HRN: </td>
<td class=\"left\">$user_hrn</td>
</tr>\n";
$slice = GeniSlice::Lookup("geni-cm", $uuid);
if ($slice) {
$slice_hrn = $slice->hrn();
$slice_creator = GeniUser::Lookup("geni-cm",
$slice->creator_uuid());
if ($slice_creator) {
$user_hrn = $slice_creator->hrn();
}
else {
$user = User::LookupByUUID($slice->creator_uuid());
if ($user) {
$user_hrn = $user->uid();
}
}
}
if (! is_null($slice_hrn)) {
echo "<tr>
<td>Geni Slice HRN: </td>
<td class=\"left\">$slice_hrn</td>
</tr>\n";
}
if (! is_null($user_hrn)) {
echo "<tr>
<td>Geni User HRN: </td>
<td class=\"left\">$user_hrn</td>
</tr>\n";
}
}
echo "</table>\n";
}
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006-2009 University of Utah and the Flux Group.
# All rights reserved.
#
#
function GetDBLink($authority)
{
if ($authority == "cm")
$authority = "geni-cm";
if ($authority == "sa")
$authority = "geni";
if ($authority == "ch")
$authority = "geni-ch";
return DBConnect($authority);
}
class GeniSlice
{
var $slice;
var $dblink;
#
# Constructor lookup.
#
function GeniSlice($authority, $token) {
$safe_token = addslashes($token);
$dblink = GetDBLink($authority);
$idx = null;
if (! $dblink) {
$this->slice = null;
return;
}
if (preg_match("/^\d+$/", $token)) {
$idx = $token;
}
elseif (preg_match("/^\w+\-\w+\-\w+\-\w+\-\w+$/", $token)) {
$query_result =
DBQueryWarn("select idx from geni_slices ".
"where uuid='$safe_token'",
$dblink);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$idx = $row[0];
}
}
elseif (preg_match("/^[-\w\.]*$/", $token)) {
$query_result =
DBQueryWarn("select idx from geni_slices ".
"where hrn='$safe_token'",
$dblink);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$idx = $row[0];
}
}
if (is_null($idx)) {
$this->slice = null;
return;
}
$query_result =
DBQueryWarn("select * from geni_slices where idx='$idx'",
$dblink);
if (!$query_result || !mysql_num_rows($query_result)) {
$this->slice = null;
return;
}
$this->dblink = $dblink;
$this->slice = mysql_fetch_array($query_result);
}
# Hmm, how does one cause an error in a php constructor?
function IsValid() {
return !is_null($this->slice);
}
# Lookup.
function Lookup($authority, $token) {
$foo = new GeniSlice($authority, $token);
if ($foo->IsValid()) {
return $foo;
}
return null;
}
# accessors
function field($name) {
return (is_null($this->slice) ? -1 : $this->slice[$name]);
}
function idx() { return $this->field('idx'); }
function hrn() { return $this->field('hrn'); }
function uuid() { return $this->field('uuid'); }
function exptidx() { return $this->field('exptidx'); }
function created() { return $this->field('created'); }
function expires() { return $this->field('expires'); }
function shutdown() { return $this->field('shutdown'); }
function locked() { return $this->field('locked'); }
function creator_uuid() { return $this->field('creator_uuid'); }
function name() { return $this->field('name'); }
function sa_uuid() { return $this->field('sa_uuid'); }
function needsfirewall(){ return $this->field('needsfirewall'); }
#
# Class function to return a list of all slices.
#
function AllSlices($authority) {
$result = array();
$dblink = GetDBLink($authority);
if (! $dblink) {
return null;
}
$query_result =
DBQueryFatal("select idx from geni_slices", $dblink);
if (! ($query_result && mysql_num_rows($query_result))) {
return null;
}
while ($row = mysql_fetch_array($query_result)) {
$idx = $row["idx"];
if (! ($slice = GeniSlice::Lookup($authority, $idx))) {
TBERROR("GeniSlice::AllSlices: ".
"Could not load slice $idx!", 1);
}
$result[] = $slice;
}
return $result;
}
function GetManifest() {
$slice_uuid = $this->uuid();
$query_result =
DBQueryFatal("select manifest from geni_manifests ".
"where slice_uuid='$slice_uuid'",
$this->dblink);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
return $row[0];
}
return null;
}
}
class GeniUser
{
var $user;
var $dblink;
#
# Constructor lookup.
#
function GeniUser($authority, $token) {
$safe_token = addslashes($token);
$dblink = GetDBLink($authority);
$idx = null;
if (! $dblink) {
$this->user = null;
return;
}
if (preg_match("/^\d+$/", $token)) {
$idx = $token;
}
elseif (preg_match("/^\w+\-\w+\-\w+\-\w+\-\w+$/", $token)) {
$query_result =
DBQueryWarn("select idx from geni_users ".
"where uuid='$safe_token'",
$dblink);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$idx = $row[0];
}
}
elseif (preg_match("/^[-\w\.]*$/", $token)) {
$query_result =
DBQueryWarn("select idx from geni_users ".
"where hrn='$safe_token'",
$dblink);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$idx = $row[0];
}
}
if (is_null($idx)) {
$this->user = null;
return;
}
$query_result =
DBQueryWarn("select * from geni_users where idx='$idx'",
$dblink);
if (!$query_result || !mysql_num_rows($query_result)) {
$this->user = null;
return;
}
$this->dblink = $dblink;
$this->user = mysql_fetch_array($query_result);
}
# Hmm, how does one cause an error in a php constructor?
function IsValid() {
return !is_null($this->user);
}
# Lookup.
function Lookup($authority, $token) {
$foo = new GeniUser($authority, $token);
if ($foo->IsValid()) {
return $foo;
}
return null;
}
# accessors
function field($name) {
return (is_null($this->user) ? -1 : $this->user[$name]);
}
function idx() { return $this->field('idx'); }
function hrn() { return $this->field('hrn'); }
function uuid() { return $this->field('uuid'); }
function exptidx() { return $this->field('exptidx'); }
function created() { return $this->field('created'); }
function expires() { return $this->field('expires'); }
function locked() { return $this->field('locked'); }
function status() { return $this->field('staus'); }
function name() { return $this->field('name'); }
function email() { return $this->field('email'); }
function sa_uuid() { return $this->field('sa_uuid'); }
}
class ClientSliver
{
var $sliver;
var $dblink;
#
# Constructor lookup.
#
function ClientSliver($token) {
$safe_token = addslashes($token);
$dblink = GetDBLink("sa");
$idx = null;
if (! $dblink) {
$this->sliver = null;
return;
}
if (preg_match("/^\d+$/", $token)) {
$idx = $token;
}
if (is_null($idx)) {
$this->sliver = null;
return;
}
$query_result =
DBQueryWarn("select * from client_slivers where idx='$idx'",
$dblink);
if (!$query_result || !mysql_num_rows($query_result)) {
$this->sliver = null;
return;
}
$this->dblink = $dblink;
$this->sliver = mysql_fetch_array($query_result);
}
# Hmm, how does one cause an error in a php constructor?
function IsValid() {
return !is_null($this->sliver);
}
# Lookup.
function Lookup($token) {
$foo = new ClientSliver($token);
if ($foo->IsValid()) {
return $foo;
}
return null;
}
# accessors
function field($name) {
return (is_null($this->sliver) ? -1 : $this->sliver[$name]);
}
function idx() { return $this->field('idx'); }
function urn() { return $this->field('urn'); }
function slice_idx() { return $this->field('slice_idx'); }
function manager_urn() { return $this->field('manager_urn'); }
function creator_idx() { return $this->field('creator_idx'); }
function created() { return $this->field('created'); }
function expires() { return $this->field('expires'); }
function locked() { return $this->field('locked'); }
function manifest() { return $this->field('manifest'); }
#
# Class function to return a list of all slivers for a slice
#
function SliverList($slice) {
$result = array();
$dblink = GetDBLink("sa");
$slice_idx = $slice->idx();
if (! $dblink) {
return null;
}
$query_result =
DBQueryFatal("select idx from client_slivers ".
"where slice_idx='$slice_idx'",
$dblink);
if (! ($query_result && mysql_num_rows($query_result))) {
return null;
}
while ($row = mysql_fetch_array($query_result)) {
$idx = $row["idx"];
if (! ($sliver = ClientSliver::Lookup($idx))) {
TBERROR("ClientSliver::SliverList: ".
"Could not load client sliver $idx!", 1);
}
$result[] = $sliver;
}
return $result;
}
}
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
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");
if (! $isadmin) {
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,
'#title' => $which);
$rows = array();
foreach ($slicelist as $slice) {
$slice_idx = $slice->idx();
$slice_hrn = $slice->hrn();
$url = CreateURL("showslice", "showtype", $type,
"slice_idx", $slice_idx);
$rows[$slice_idx] =
array($slice_idx => "<a href='$url'>$slice_hrn</a>");
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -295,6 +295,7 @@ function WRITESIDEBAR() {
global $login_status, $login_user, $pid, $gid;
global $TBBASE, $TBDOCBASE, $BASEPATH, $WIKISUPPORT, $MAILMANSUPPORT;
global $BUGDBSUPPORT, $BUGDBURL, $CVSSUPPORT, $CHATSUPPORT, $TRACSUPPORT;
global $PROTOGENI;
global $CHECKLOGIN_WIKINAME, $TBMAINSITE;
global $THISHOMEBASE;
global $EXPOSETEMPLATES;
......@@ -743,6 +744,10 @@ function WRITESIDEBAR() {
}
NavMenuButtonNew("Approve Widearea User",
"$TBBASE/approvewauser_form.php3");
if ($PROTOGENI) {
NavMenuButton("ProtoGeni Slices",
"$TBBASE/genislices.php");
}
}
if (0 && $login_user) {
NavMenuSection("Status", "Status");
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# 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");
if (! $isadmin) {
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());
$rows[] = array("uuid" => $slice->uuid());
$rows[] = array("created" => $slice->created());
$rows[] = array("expires" => $slice->expires());
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) {
$rows[] = array("Creator" => $geniuser->hrn());
}
else {
$user = User::LookupByUUID($slice->creator_uuid());
if ($user) {
$rows[] = array("Creator" => $user->uid());
}
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
$clientslivers = ClientSliver::SliverList($slice);
if ($clientslivers && count($clientslivers)) {
$table = array('#id' => 'clientslivers',
'#title' => "Client Slivers");
$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>";
}
$rows[] = $row;
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -114,6 +114,7 @@ $url_mapping["cvswebwrap"] = "cvsweb/cvswebwrap.php3";
$url_mapping["profile"] = "profile.php";
$url_mapping["submitpub"] = "submitpub.php";
$url_mapping["showslice"] = "showslice.php";
$url_mapping["showmanifest"] = "showmanifest.php";
#
# The caller will pass in a page id, and a list of things. If the thing
......
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