nodecontrol_form.php3 6.61 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
$query_result =
27 28 29
    DBQueryFatal("select n.*,r.vname from nodes as n ".
		 "left join reserved as r on n.node_id=r.node_id ".
		 "where n.node_id='$node_id'");
30
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
31
  USERERROR("The node $node_id is not a valid nodeid!", 1);
32 33 34 35 36 37
}
$row = mysql_fetch_array($query_result);

#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
38 39 40
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
41
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
42 43
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
44 45 46 47
}

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

59
#
60 61 62 63
# 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.
64 65
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
66 67 68 69 70
    $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");
71 72
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
73 74 75 76 77 78 79 80
    $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");
81 82
}

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

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

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

100 101 102 103 104 105 106 107 108
if ($vname) {
    echo "<tr>
              <td>Virtual Name:</td>
              <td class=left> 
                  <input type=readonly name=vname value='$vname'>
                  </td>
          </tr>\n";
}

109 110 111 112 113 114 115 116
echo "<tr>
          <td>Node Type:</td>
          <td class=\"left\"> 
              <input type=\"readonly\" name=\"node_type\" value=\"$type\">
              </td>
      </tr>\n";

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

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

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


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

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 197
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";
}
198

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


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

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

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

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

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