nodecontrol_form.php3 7.11 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3 4 5 6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
7 8
include("defs.php3");

9 10 11 12 13
#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

14 15 16
#
# Only known and logged in users can do this.
#
17
$uid = GETLOGIN();
18 19
LOGGEDINORDIE($uid);

20 21 22 23 24 25 26 27
#
# Verify form arguments.
# 
if (!isset($node_id) ||
    strcmp($node_id, "") == 0) {
    USERERROR("You must provide a node ID.", 1);
}

28
#
29 30
# Check to make sure that this is a valid nodeid
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
31
$query_result =
32 33 34
    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'");
35
if (mysql_num_rows($query_result) == 0) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
36
  USERERROR("The node $node_id is not a valid nodeid!", 1);
37 38 39 40 41 42
}
$row = mysql_fetch_array($query_result);

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

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

64
#
65 66 67 68
# 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.
69 70
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
71
    $osid_result =
72 73
	DBQueryFatal("select o.osname, o.pid, o.osid as oosid, " .
		     "p.osid as posid from os_info as o ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
74
		     "left join partitions as p on o.osid=p.osid ".
75 76
		     "where p.node_id='$node_id' or ".
		     "(o.path!='' and o.path is not NULL) ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
77
		     "order by o.osid");
78 79
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
80
    $osid_result =
81 82
	DBQueryFatal("select distinct o.osname, o.pid, o.osid as oosid," .
		     "p.osid as posid from os_info as o ".
83
		     "left join group_membership as m on m.pid=o.pid ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
84
		     "left join partitions as p on o.osid=p.osid ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
85 86 87
		     "where p.node_id='$node_id' or ".
		     "  ((m.uid='$uid' or o.shared=1) and ".
		     "   (o.path!='' and o.path is not NULL)) ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
88
		     "order by o.pid,o.osid");
89 90
}

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

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

108 109 110 111
if ($vname) {
    echo "<tr>
              <td>Virtual Name:</td>
              <td class=left> 
112
                  <input readonly type=readonly name=vname value='$vname'>
113 114 115 116
                  </td>
          </tr>\n";
}

117 118 119
echo "<tr>
          <td>Node Type:</td>
          <td class=\"left\"> 
120
              <input readonly type=readonly name=node_type value=\"$type\">
121 122 123 124
              </td>
      </tr>\n";

#
125 126
# OSID, as a menu of those allowed.
#
127
echo "<tr>
128 129 130 131
          <td>*Def Boot OS:</td>";
echo "    <td><select name=def_boot_osid>\n";
if ($def_boot_osid && TBOSInfo($def_boot_osid, $osname, $ospid)) {
    echo "<option selected value='$def_boot_osid'>$osname </option>\n";
132
}
133
               while ($row = mysql_fetch_array($osid_result)) {
134
                  $osname = $row[osname];
135 136
                  $oosid = $row[oosid];
		  $posid = $row[posid];
137 138
		  $pid  = $row[pid];

139 140 141 142 143 144 145 146
		  # Use the osid that came from the partitions table, if there
		  # was one - otherwise, go with the os_info table
		  if ($posid) {
		  	$osid = $posid;
		  } else {
		  	$osid = $oosid;
		  }

147
		  if ($def_boot_osid == $osid) {
148
		      continue;
149
		  }
150
                  echo "<option value=$osid>$pid - $osname</option>\n";
151 152
               }
if ($isadmin) {
153
    echo "<option value=\"\">No OS</option>\n";
154 155 156
}
echo "       </select>";
echo "    </td>
157 158
      </tr>\n";

159 160 161 162 163 164 165 166
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";


167 168 169 170 171 172 173
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";

174 175 176 177
if ($isadmin) {
    mysql_data_seek($osid_result, 0);

    echo "<tr>
178
              <td>Next Boot OS:</td>";
179
    echo "    <td><select name=\"next_boot_osid\">\n";
180
    echo "                <option value=\"\">No OS</option>\n";
181 182
    
    while ($row = mysql_fetch_array($osid_result)) {
183
	$osname = $row[osname];
184 185 186 187 188 189 190
	$osid = $row[osid];
	$pid  = $row[pid];

	echo "<option ";
	if ($next_boot_osid == $osid) {
	    echo "selected ";
	}
191
	echo "value=\"$osid\">$pid - $osname</option>\n";
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
    }
    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";
}
212

213
echo "<tr>
214
          <td>Startup Command[<b>1</b>]:</td>
215 216
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
217
                     maxlength=\"256\" value='$startupcmd'></td>
218 219 220
      </tr>\n";


221
echo "<tr>
222
          <td>RPMs[<b>2</b>]:</td>
223 224
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
225
                     maxlength=\"1024\" value=\"$rpms\"></td>
226 227
      </tr>\n";

228
echo "<tr>
229
          <td>Tarballs[<b>3</b>]:</td>
230 231 232 233 234
          <td class=\"left\">
              <input type=\"text\" name=\"tarballs\" size=\"60\"
                     maxlength=\"1024\" value=\"$tarballs\"></td>
      </tr>\n";

235 236 237 238 239 240 241 242
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

243 244 245
echo "<p><blockquote><blockquote>
      <ol>
        <li> Node startup command must be a pathname. You may also include
246
                optional arguments.
247 248
        <li> RPMs must be a colon separated list of pathnames.
        <li> Tarballs must be a colon separated list of directory path
Leigh B. Stoller's avatar
Leigh B. Stoller committed
249
                and tarfile path (/usr/site:/foo/fee.tar.gz). The
250
                directory is where the tarfile should be unpacked.
251 252
      </ol>
      </blockquote></blockquote>\n";
253

254 255 256 257 258
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>