nodecontrol_form.php3 4.34 KB
Newer Older
1 2 3
<?php
include("defs.php3");

4 5 6 7 8
#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

9 10 11
#
# Only known and logged in users can do this.
#
12
$uid = GETLOGIN();
13 14
LOGGEDINORDIE($uid);

15 16 17 18 19 20 21 22
#
# Verify form arguments.
# 
if (!isset($node_id) ||
    strcmp($node_id, "") == 0) {
    USERERROR("You must provide a node ID.", 1);
}

23
#
24 25 26 27 28 29 30 31 32 33 34 35
# Check to make sure that this is a valid nodeid
#
$query_result = mysql_db_query($TBDBNAME,
	"SELECT * FROM nodes WHERE node_id=\"$node_id\"");
if (mysql_num_rows($query_result) == 0) {
  USERERROR("The node $node_id is not a valid nodeid", 1);
}
$row = mysql_fetch_array($query_result);

#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
36 37 38
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
39
    $query_result = mysql_db_query($TBDBNAME,
40 41 42
	"select proj_memb.* from proj_memb left join reserved ".
	"on proj_memb.pid=reserved.pid and proj_memb.uid='$uid' ".
	"where reserved.node_id='$node_id'");
43
    if (mysql_num_rows($query_result) == 0) {
44 45
        USERERROR("The node $node_id is not in an experiment ".
		  "or not in the same project as you", 1);
46 47
    }
    $foorow = mysql_fetch_array($query_result);
48 49
    $trust = $foorow[trust];
    if ($trust != "local_root" && $trust != "group_root") {
50 51
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
52 53 54 55 56
}

$node_id            = $row[node_id]; 
$type               = $row[type];
$def_boot_image_id  = $row[def_boot_image_id];
57
$def_boot_path      = $row[def_boot_path];
58 59 60
$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];
61
$rpms               = $row[rpms];
62
$startupcmd         = $row[startupcmd];
63 64 65 66 67

echo "<table border=2 cellpadding=0 cellspacing=2
       align='center'>\n";

#
68 69
# Generate the form. Note that $refer is set by the caller so we know
# how we got to the nodecontrol page. 
70
# 
71
echo "<form action=\"nodecontrol.php3?refer=$refer\"
72
            method=\"post\">\n";
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

echo "<tr>
          <td>Node ID:</td>
          <td class=\"left\"> 
              <input type=\"readonly\" name=\"node_id\" value=\"$node_id\">
              </td>
      </tr>\n";

echo "<tr>
          <td>Node Type:</td>
          <td class=\"left\"> 
              <input type=\"readonly\" name=\"node_type\" value=\"$type\">
              </td>
      </tr>\n";

#
# This should be a menu.
# 
echo "<tr>
          <td>Def Boot Image:</td>
          <td class=\"left\">
94
              <input type=\"text\" name=\"def_boot_image_id\" size=\"30\"
95 96 97
                     value=\"$def_boot_image_id\"></td>
      </tr>\n";

98 99 100 101 102 103 104 105
echo "<tr>
          <td>Def Boot Path:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"def_boot_path\" size=\"40\"
                     value=\"$def_boot_path\"></td>
      </tr>\n";


106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
echo "<tr>
          <td>Def Boot Command Line:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"def_boot_cmd_line\" size=\"40\"
                     value=\"$def_boot_cmd_line\"></td>
      </tr>\n";


echo "<tr>
          <td>Next Boot Path:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"next_boot_path\" size=\"40\"
                     value=\"$next_boot_path\"></td>
      </tr>\n";


echo "<tr>
          <td>Next Boot Command Line:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"next_boot_cmd_line\" size=\"40\"
                     value=\"$next_boot_cmd_line\"></td>
      </tr>\n";


130
echo "<tr>
131
          <td>Startup Command[1]:</td>
132 133
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
134
                     maxlength=\"256\" value=\"$startupcmd\"></td>
135 136 137
      </tr>\n";


138 139 140 141
echo "<tr>
          <td>RPMs[2]:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
142
                     maxlength=\"1024\" value=\"$rpms\"></td>
143 144
      </tr>\n";

145 146 147 148 149 150 151 152
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

153 154 155 156 157 158
echo "<p>
      <dl COMPACT>
        <dt> [1]
           <dd> Node startup command must be a pathname. You may also include
                optional arguments.
        <dt> [2]
159
           <dd> RPMs must be a colon separated list of pathnames.
160 161
      </dl>\n";

162 163 164 165 166
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>