diff --git a/www/defs.php3.in b/www/defs.php3.in index 8b3b368083b306f4d7fbaf6ac15e19e4a4429d7c..81fe451f18d6ff8669fbf43e49272c4c464ffbc8 100644 --- a/www/defs.php3.in +++ b/www/defs.php3.in @@ -1,7 +1,7 @@ XML'); + myWindow.document.write('' + text + ''); + myWindow.document.close(); +} + diff --git a/www/experiment_defs.php b/www/experiment_defs.php index 315ee8a3f7598d6095ff95c19d4e2723e4aeecbc..c25f80ab7ec62655bf208614d9fde5d35a3ed886 100644 --- a/www/experiment_defs.php +++ b/www/experiment_defs.php @@ -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 \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 " - Geni Slice HRN: - $slice_hrn - \n"; - } - if (! is_null($user_hrn)) { - echo " - Geni User HRN: - $user_hrn - \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 " + Geni Slice HRN: + $slice_hrn + \n"; + } + if (! is_null($user_hrn)) { + echo " + Geni User HRN: + $user_hrn + \n"; + } } echo "\n"; } diff --git a/www/geni_defs.php b/www/geni_defs.php new file mode 100644 index 0000000000000000000000000000000000000000..507f1eced4aa6207f25f9c6dd7b0887224282a4a --- /dev/null +++ b/www/geni_defs.php @@ -0,0 +1,348 @@ +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; + } +} + diff --git a/www/genislices.php b/www/genislices.php new file mode 100644 index 0000000000000000000000000000000000000000..6d3d01c0b58d56d83bfc55a42b60cf320e8ec679 --- /dev/null +++ b/www/genislices.php @@ -0,0 +1,77 @@ +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 => "$slice_hrn"); + } + list ($html, $button) = TableRender($table, $rows); + echo $html; +} + +# +# Standard Testbed Footer +# +PAGEFOOTER(); +?> + diff --git a/www/menu.php3 b/www/menu.php3 index a1db9e0c9fb3f994eb3dd7d2ad04958e1dba3e4e..1dd24927be052532d76934dd6c5632862831f9a1 100644 --- a/www/menu.php3 +++ b/www/menu.php3 @@ -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"); diff --git a/www/showslice.php b/www/showslice.php new file mode 100644 index 0000000000000000000000000000000000000000..4a273bc8cc395f51aa645003a402951928f64d30 --- /dev/null +++ b/www/showslice.php @@ -0,0 +1,123 @@ +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" => + "". + "Click to View"); +} + +$experiment = Experiment::LookupByUUID($slice->uuid()); +if ($experiment) { + $eid = $experiment->eid(); + $exptidx = $experiment->idx(); + $url = CreateURL("showexp", $experiment); + $rows[] = array("Experiment" => "$eid ($exptidx)"); +} + +$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"] = + "". + "Manifest"; + } + $rows[] = $row; + } + + list ($html, $button) = TableRender($table, $rows); + echo $html; +} + +# +# Standard Testbed Footer +# +PAGEFOOTER(); +?> + diff --git a/www/url_defs.php b/www/url_defs.php index fa4f82ca10f54934cce9cde927c2c135f76a07fe..388c7520dff68dd7a5ea09c90887658a4aeac68f 100644 --- a/www/url_defs.php +++ b/www/url_defs.php @@ -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