nodecontrol_form.php3 6.3 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
# Check to make sure that this is a valid nodeid
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
26 27
$query_result =
    DBQueryFatal("SELECT * FROM nodes WHERE node_id='$node_id'");
28
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
29
  USERERROR("The node $node_id is not a valid nodeid!", 1);
30 31 32 33 34 35
}
$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) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
39
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
40 41
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
42 43 44 45
}

$node_id            = $row[node_id]; 
$type               = $row[type];
46
$def_boot_osid      = $row[def_boot_osid];
47
$def_boot_path      = $row[def_boot_path];
48
$def_boot_cmd_line  = $row[def_boot_cmd_line];
49
$next_boot_osid     = $row[next_boot_osid];
50 51
$next_boot_path     = $row[next_boot_path];
$next_boot_cmd_line = $row[next_boot_cmd_line];
52
$rpms               = $row[rpms];
53
$tarballs           = $row[tarballs];
54
$startupcmd         = $row[startupcmd];
55

56
#
57 58 59 60
# Get the OSID list. These are either OSIDs that are currently loaded on
# the node as indicated by the partitions table, or OSIDs with non-null
# paths (which means they are OSKit kernels). The list is pruned using the
# pid of the user when not an admin type, of course.
61 62
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
63 64 65 66 67
    $osid_result =
	DBQueryFatal("select o.*,p.osid from os_info as o ".
		     "left join partitions as p on o.osid=p.osid ".
		     "where p.node_id='$node_id' or o.path!='' ".
		     "order by o.osid");
68 69
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
70 71 72 73 74 75 76 77
    $osid_result =
	DBQueryFatal("select distinct o.*,p.osid from os_info as o ".
		     "left join group_membership as m ".
		     " on o.pid IS NULL or m.pid=o.pid ".
		     "left join partitions as p on o.osid=p.osid ".
		     "where m.uid='$uid' and p.node_id='$node_id' ".
		     " or o.path!='' ".
		     "order by o.pid,o.osid");
78 79
}

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

#
84 85
# Generate the form. Note that $refer is set by the caller so we know
# how we got to the nodecontrol page. 
86
# 
87
echo "<form action=\"nodecontrol.php3?refer=$refer\"
88
            method=\"post\">\n";
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

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";

#
105 106
# OSID, as a menu of those allowed.
#
107
echo "<tr>
108 109
          <td>*Def Boot OSID:</td>";
echo "    <td><select name=\"def_boot_osid\">\n";
110 111 112
if ($def_boot_osid) {
    echo "<option selected value='$def_boot_osid'>$def_boot_osid</option>\n";
}
113 114 115 116 117 118 119 120
               while ($row = mysql_fetch_array($osid_result)) {
                  $osid = $row[osid];
		  $pid  = $row[pid];
		  if (!$pid)
		      $pid = "testbed";

                  echo "<option ";
		  if ($def_boot_osid == $osid) {
121
		      continue;
122 123 124 125
		  }
                  echo "value=\"$osid\">$pid - $osid</option>\n";
               }
if ($isadmin) {
126
    echo "<option value=\"\">No OSID</option>\n";
127 128 129
}
echo "       </select>";
echo "    </td>
130 131
      </tr>\n";

132 133 134 135 136 137 138 139
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";


140 141 142 143 144 145 146
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";

147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
if ($isadmin) {
    mysql_data_seek($osid_result, 0);

    echo "<tr>
              <td>Next Boot OSID:</td>";
    echo "    <td><select name=\"next_boot_osid\">\n";
    echo "                <option value=\"\">No OSID</option>\n";
    
    while ($row = mysql_fetch_array($osid_result)) {
	$osid = $row[osid];
	$pid  = $row[pid];
	if (!$pid)
	    $pid = "testbed";

	echo "<option ";
	if ($next_boot_osid == $osid) {
	    echo "selected ";
	}
	echo "value=\"$osid\">$pid - $osid</option>\n";
    }
    echo "       </select>";
    echo "    </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";
}
186

187
echo "<tr>
188
          <td>Startup Command[1]:</td>
189 190
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
191
                     maxlength=\"256\" value=\"$startupcmd\"></td>
192 193 194
      </tr>\n";


195 196 197 198
echo "<tr>
          <td>RPMs[2]:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
199
                     maxlength=\"1024\" value=\"$rpms\"></td>
200 201
      </tr>\n";

202 203 204 205 206 207 208
echo "<tr>
          <td>Tarballs[3]:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"tarballs\" size=\"60\"
                     maxlength=\"1024\" value=\"$tarballs\"></td>
      </tr>\n";

209 210 211 212 213 214 215 216
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

217 218 219 220 221 222
echo "<p>
      <dl COMPACT>
        <dt> [1]
           <dd> Node startup command must be a pathname. You may also include
                optional arguments.
        <dt> [2]
223
           <dd> RPMs must be a colon separated list of pathnames.
224 225 226 227
        <dt> [3]
           <dd> Tarballs must be a colon separated list of directory path
                and tarfile path (eg: /usr/site /foo/fee.tar.gz). The
                directory is where the tarfile should be unpacked.
228 229
      </dl>\n";

230 231 232 233 234
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>