nodecontrol_form.php3 7.54 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2002, 2004 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# 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_cmd_line  = $row[def_boot_cmd_line];
56
$next_boot_osid     = $row[next_boot_osid];
57
$next_boot_cmd_line = $row[next_boot_cmd_line];
58
$temp_boot_osid     = $row[temp_boot_osid];
59
$rpms               = $row[rpms];
60
$tarballs           = $row[tarballs];
61
$startupcmd         = $row[startupcmd];
62

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

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

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

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

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

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

#
124 125
# OSID, as a menu of those allowed.
#
126
echo "<tr>
127 128 129 130
          <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";
131
}
132
               while ($row = mysql_fetch_array($osid_result)) {
133
                  $osname = $row[osname];
134 135
                  $oosid = $row[oosid];
		  $posid = $row[posid];
136 137
		  $pid  = $row[pid];

138 139 140 141 142 143 144 145
		  # 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;
		  }

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

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

165 166 167 168
if ($isadmin) {
    mysql_data_seek($osid_result, 0);

    echo "<tr>
169
              <td>Next Boot OS:</td>";
170
    echo "    <td><select name=\"next_boot_osid\">\n";
171
    echo "                <option value=\"\">No OS</option>\n";
172 173
    
    while ($row = mysql_fetch_array($osid_result)) {
174
	$osname = $row[osname];
175 176 177 178 179 180 181 182 183 184 185
	$oosid = $row[oosid];
	$posid = $row[posid];

        # 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;
	}
186 187 188 189 190

	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
    }
    echo "       </select>";
    echo "    </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";
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233

    mysql_data_seek($osid_result, 0);

    echo "<tr>
              <td>Temp Boot OS:</td>";
    echo "    <td><select name=\"temp_boot_osid\">\n";
    echo "                <option value=\"\">No OS</option>\n";
    
    while ($row = mysql_fetch_array($osid_result)) {
	$osname = $row[osname];
	$oosid = $row[oosid];
	$posid = $row[posid];

        # 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;
	}

	echo "<option ";
	if ($temp_boot_osid == $osid) {
	    echo "selected ";
	}
	echo "value=\"$osid\">$pid - $osname</option>\n";
    }
    echo "       </select>";
    echo "    </td>
           </tr>\n";
234
}
235

236
echo "<tr>
237
          <td>Startup Command[<b>1</b>]:</td>
238 239
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
240
                     maxlength=\"256\" value='$startupcmd'></td>
241 242 243
      </tr>\n";


244
echo "<tr>
245
          <td>RPMs[<b>2</b>]:</td>
246 247
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
248
                     maxlength=\"1024\" value=\"$rpms\"></td>
249 250
      </tr>\n";

251
echo "<tr>
252
          <td>Tarballs[<b>3</b>]:</td>
253 254 255 256 257
          <td class=\"left\">
              <input type=\"text\" name=\"tarballs\" size=\"60\"
                     maxlength=\"1024\" value=\"$tarballs\"></td>
      </tr>\n";

258 259 260 261 262 263 264 265
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

266 267 268
echo "<p><blockquote><blockquote>
      <ol>
        <li> Node startup command must be a pathname. You may also include
269
                optional arguments.
270 271
        <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
272
                and tarfile path (/usr/site:/foo/fee.tar.gz). The
273
                directory is where the tarfile should be unpacked.
274 275
      </ol>
      </blockquote></blockquote>\n";
276

277 278 279 280 281
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>