experimentrun_show.php 2.83 KB
Newer Older
1 2 3 4 5 6 7
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
8
include_once("template_defs.php");
9 10 11
require("Sajax.php");
sajax_init();
sajax_export("GraphShow");
12 13 14 15 16 17 18 19 20 21 22 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

#
# Only known and logged in users ...
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);

#
# Verify page arguments.
# 
if (!isset($exptidx) ||
    strcmp($exptidx, "") == 0) {
    USERERROR("You must provide an instance ID", 1);
}
if (!isset($runidx) ||
    strcmp($runidx, "") == 0) {
    USERERROR("You must provide an run ID", 1);
}
if (!isset($guid) ||
    strcmp($guid, "") == 0) {
    USERERROR("You must provide a template ID", 1);
}
if (!isset($version) ||
    strcmp($version, "") == 0) {
    USERERROR("You must provide a template version number", 1);
}
if (!TBvalid_guid($guid)) {
    PAGEARGERROR("Invalid characters in GUID!");
}
if (!TBvalid_integer($version)) {
    PAGEARGERROR("Invalid characters in version!");
}
if (!TBvalid_integer($exptidx)) {
    PAGEARGERROR("Invalid characters in instance ID!");
}
if (!TBvalid_integer($runidx)) {
    PAGEARGERROR("Invalid characters in run ID!");
}

#
53
# Check to make sure this is a valid template and user has permission.
54
#
55 56
$template = Template::Lookup($guid, $version);
if (!$template) {
57 58 59
    USERERROR("The experiment template $guid/$version is not a valid ".
              "experiment template!", 1);
}
60 61 62 63 64 65
if (! $template->AccessCheck($uid, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment template ".
	      "$guid/$version!", 1);
}
$instance = TemplateInstance::LookupByExptidx($exptidx);
if (!$instance) {
66 67 68
    USERERROR("The instance $exptidx is not a valid instance in ".
              "template $guid/$version!", 1);
}
69
if (! $instance->ValidRun($runidx)) {
70 71 72
    USERERROR("The run $runidx is not a valid experiment run!", 1);
}

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#
# For the Sajax Interface
#
function GraphShow($which, $arg0, $arg1)
{
    global $template, $instance, $runidx;

    ob_start();
    $instance->ShowGraphArea($which, $runidx, $arg0, $arg1);
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}

#
# See if this request is to the above function. Does not return
# if it is. Otherwise return and continue on.
#
sajax_handle_client_request();

#
# Standard Testbed Header after argument checking.
#
PAGEHEADER("Experiment Run");

98 99 100 101 102 103 104
echo "<font size=+2>Experiment Run<b> " .
         MakeLink("instance",
		  "guid=$guid&version=$version&exptidx=$exptidx",
		  "$guid/$version/$exptidx") . 
      "</b></font>\n";
echo "<br><br>\n";

105
$instance->ShowRun($runidx);
106

107 108 109 110 111 112 113
echo "<script type='text/javascript' language='javascript'>\n";
sajax_show_javascript();
echo "</script>\n";

#
# Throw up graph stuff.
#
114
if (0) {
115 116 117 118
echo "<center>\n";
echo "<br>";
$instance->ShowGraphArea("pps", $runidx);
echo "</center>\n";
119
} 
120

121 122 123 124 125
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>