nodecontrol_form.php3 6.79 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
}

$node_id            = $row[node_id]; 
$type               = $row[type];
56
$def_boot_osid      = $row[def_boot_osid];
57
$def_boot_path      = $row[def_boot_path];
58
$def_boot_cmd_line  = $row[def_boot_cmd_line];
59
$next_boot_osid     = $row[next_boot_osid];
60 61
$next_boot_path     = $row[next_boot_path];
$next_boot_cmd_line = $row[next_boot_cmd_line];
62
$rpms               = $row[rpms];
63
$tarballs           = $row[tarballs];
64
$startupcmd         = $row[startupcmd];
65

66
#
67 68 69 70
# 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.
71 72 73
#
if ($isadmin) {
    $osid_result = mysql_db_query($TBDBNAME,
74 75 76
	"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");
77 78 79
}
else {
    $osid_result = mysql_db_query($TBDBNAME,
80 81 82 83 84
	"select distinct o.*,p.osid from os_info as o ".
	"left join proj_memb 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");
85 86 87 88 89 90
}
if (! $osid_result) {
    $err = mysql_error();
    TBERROR("Database Error getting OSID list: $err\n", 1);
}

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

#
95 96
# Generate the form. Note that $refer is set by the caller so we know
# how we got to the nodecontrol page. 
97
# 
98
echo "<form action=\"nodecontrol.php3?refer=$refer\"
99
            method=\"post\">\n";
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

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

#
116 117
# OSID, as a menu of those allowed.
#
118
echo "<tr>
119 120
          <td>*Def Boot OSID:</td>";
echo "    <td><select name=\"def_boot_osid\">\n";
121 122 123
if ($def_boot_osid) {
    echo "<option selected value='$def_boot_osid'>$def_boot_osid</option>\n";
}
124 125 126 127 128 129 130 131
               while ($row = mysql_fetch_array($osid_result)) {
                  $osid = $row[osid];
		  $pid  = $row[pid];
		  if (!$pid)
		      $pid = "testbed";

                  echo "<option ";
		  if ($def_boot_osid == $osid) {
132
		      continue;
133 134 135 136
		  }
                  echo "value=\"$osid\">$pid - $osid</option>\n";
               }
if ($isadmin) {
137
    echo "<option value=\"\">No OSID</option>\n";
138 139 140
}
echo "       </select>";
echo "    </td>
141 142
      </tr>\n";

143 144 145 146 147 148 149 150
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";


151 152 153 154 155 156 157
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";

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 186 187 188 189 190 191 192 193 194 195 196
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";
}
197

198
echo "<tr>
199
          <td>Startup Command[1]:</td>
200 201
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
202
                     maxlength=\"256\" value=\"$startupcmd\"></td>
203 204 205
      </tr>\n";


206 207 208 209
echo "<tr>
          <td>RPMs[2]:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
210
                     maxlength=\"1024\" value=\"$rpms\"></td>
211 212
      </tr>\n";

213 214 215 216 217 218 219
echo "<tr>
          <td>Tarballs[3]:</td>
          <td class=\"left\">
              <input type=\"text\" name=\"tarballs\" size=\"60\"
                     maxlength=\"1024\" value=\"$tarballs\"></td>
      </tr>\n";

220 221 222 223 224 225 226 227
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

228 229 230 231 232 233
echo "<p>
      <dl COMPACT>
        <dt> [1]
           <dd> Node startup command must be a pathname. You may also include
                optional arguments.
        <dt> [2]
234
           <dd> RPMs must be a colon separated list of pathnames.
235 236 237 238
        <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.
239 240
      </dl>\n";

241 242 243 244 245
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>