showexp.php3 4.99 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1 2
<?php
include("defs.php3");
3
include("showstuff.php3");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
4

5 6 7 8 9
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information");

10 11 12
#
# Only known and logged in users can end experiments.
#
13
$uid = GETLOGIN();
14
LOGGEDINORDIE($uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
15

16 17
$isadmin = ISADMIN($uid);

Leigh B. Stoller's avatar
Leigh B. Stoller committed
18
#
19 20
# Verify form arguments.
# 
21 22 23 24 25
if (!isset($exp_pideid) ||
    strcmp($exp_pideid, "") == 0) {
    USERERROR("You must provide an experiment ID.", 1);
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
26
#
27 28 29 30 31 32 33
# First get the project (PID) from the form parameter, which came in
# as <pid>$$<eid>.
#
$exp_eid = strstr($exp_pideid, "$$");
$exp_eid = substr($exp_eid, 2);
$exp_pid = substr($exp_pideid, 0, strpos($exp_pideid, "$$", 0));

Leigh B. Stoller's avatar
Leigh B. Stoller committed
34
#
35
# Check to make sure thats this is a valid PID/EID tuple.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
36 37
#
$query_result = mysql_db_query($TBDBNAME,
38 39 40 41 42
	"SELECT * FROM experiments WHERE ".
        "eid=\"$exp_eid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($query_result) == 0) {
  USERERROR("The experiment $exp_eid is not a valid experiment ".
            "in project $exp_pid.", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
43
}
44
$exprow = mysql_fetch_array($query_result);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
45

46 47 48 49
#
# Verify that this uid is a member of the project for the experiment
# being displayed.
#
50 51
if (!$isadmin) {
    $query_result = mysql_db_query($TBDBNAME,
52
	"SELECT pid FROM proj_memb WHERE uid=\"$uid\" and pid=\"$exp_pid\"");
53 54 55 56
    if (mysql_num_rows($query_result) == 0) {
        USERERROR("You are not a member of Project $exp_pid for ".
                  "Experiment: $exp_eid.", 1);
    }
Leigh B. Stoller's avatar
Leigh B. Stoller committed
57 58 59 60 61 62 63 64 65
}
?>

<center>
<h1>Experiment Information</h1>
<table align="center" border="1">

<?php

66 67 68 69 70 71 72
$exp_expires = $exprow[expt_expires];
$exp_name    = $exprow[expt_name];
$exp_created = $exprow[expt_created];
$exp_start   = $exprow[expt_start];
$exp_end     = $exprow[expt_end];
$exp_created = $exprow[expt_created];
$exp_head    = $exprow[expt_head_uid];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

#
# Generate the table.
# 
echo "<tr>
          <td>Name: </td>
          <td class=\"left\">$exp_eid</td>
      </tr>\n";

echo "<tr>
          <td>Long Name: </td>
          <td class=\"left\">$exp_name</td>
      </tr>\n";

echo "<tr>
          <td>Project: </td>
89
          <td class=\"left\">$exp_pid</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
90 91 92
      </tr>\n";

echo "<tr>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
93
          <td>Experiment Head: </td>
94
          <td class=\"left\">
95
              <A href='showuser.php3?target_uid=$exp_head'>
96
                 $exp_head</td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
      </tr>\n";

echo "<tr>
          <td>Created: </td>
          <td class=\"left\">$exp_created</td>
      </tr>\n";

echo "<tr>
          <td>Starts: </td>
          <td class=\"left\">$exp_start</td>
      </tr>\n";

echo "<tr>
          <td>Ends: </td>
          <td class=\"left\">$exp_end</td>
      </tr>\n";

echo "<tr>
          <td>Expires: </td>
          <td class=\"left\">$exp_expires</td>
      </tr>\n";

?>
</table>
121 122 123 124 125 126 127 128 129 130 131 132 133

<?php

#
# Suck out the node information.
# 
$reserved_result = mysql_db_query($TBDBNAME,
	"SELECT * FROM reserved WHERE ".
        "eid=\"$exp_eid\" and pid=\"$exp_pid\"");
if (mysql_num_rows($reserved_result)) {
    echo "<h3>Reserved Nodes</h3>
          <table align=center border=1>
          <tr>
134 135
              <td align=center>Change</td>
              <td align=center>Node ID</td>
136
              <td align=center>Node Name</td>
137 138 139 140
              <td align=center>Type</td>
              <td align=center>Default<br>Image</td>
              <td align=center>Default<br>Path</td>
              <td align=center>Default<br>Cmdline</td>
141 142 143 144 145 146
          </tr>\n";

    #
    # I'm so proud!
    #
    $query_result = mysql_db_query($TBDBNAME,
147
	"SELECT nodes.*,reserved.vname ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
148
        "FROM nodes LEFT JOIN reserved ".
149
        "ON nodes.node_id=reserved.node_id ".
150 151
        "WHERE reserved.eid=\"$exp_eid\" and reserved.pid=\"$exp_pid\" ".
        "ORDER BY type,node_id");
152 153 154

    while ($row = mysql_fetch_array($query_result)) {
        $node_id = $row[node_id];
155
        $vname   = $row[vname];
156
        $type    = $row[type];
157
        $def_boot_image_id  = $row[def_boot_image_id];
158
        $def_boot_path      = $row[def_boot_path];
159 160 161 162 163 164
        $def_boot_cmd_line  = $row[def_boot_cmd_line];
        $next_boot_path     = $row[next_boot_path];
        $next_boot_cmd_line = $row[next_boot_cmd_line];

        if (!$def_boot_cmd_line)
            $def_boot_cmd_line = "NULL";
165 166
        if (!$def_boot_path)
            $def_boot_path = "NULL";
167 168 169 170
        if (!$next_boot_path)
            $next_boot_path = "NULL";
        if (!$next_boot_cmd_line)
            $next_boot_cmd_line = "NULL";
171 172
        if (!$vname)
            $vname = "--";
173

174
        echo "<tr>
175
                  <td align=center>
176
                     <A href='nodecontrol_form.php3?node_id=$node_id&refer=$exp_pideid'>
177
                     <img alt=\"o\" src=\"redball.gif\"></A></td>
178
                  <td>$node_id</td>
179
                  <td>$vname</td>
180
                  <td>$type</td>
181
                  <td>$def_boot_image_id</td>
182
                  <td>$def_boot_path</td>
183
                  <td>$def_boot_cmd_line</td>
184 185 186 187 188
              </tr>\n";
    }
    echo "</table>\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
189 190
#
# Lets dump the project information too.
191
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
192 193
echo "<center>
      <h3>Project Information</h3>
194
      </center>\n";
195
SHOWPROJECT($exp_pid, $uid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
196

197 198 199 200
#
# Standard Testbed Footer
# 
PAGEFOOTER();
201
?>