nodecontrol_form.php3 6.71 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 72 73 74 75
    $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");
76 77
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
78 79
    $osid_result =
	DBQueryFatal("select distinct o.*,p.osid from os_info as o ".
80
		     "left join group_membership as m on m.pid=o.pid ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
81 82
		     "left join partitions as p on o.osid=p.osid ".
		     "where m.uid='$uid' and p.node_id='$node_id' ".
83
		     " or o.path!='' or o.shared=1 ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
84
		     "order by o.pid,o.osid");
85 86
}

87 88 89 90
echo "<table border=2 cellpadding=0 cellspacing=2
       align='center'>\n";

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

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

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

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

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

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

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


154 155 156 157 158 159 160
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";

161 162 163 164
if ($isadmin) {
    mysql_data_seek($osid_result, 0);

    echo "<tr>
165
              <td>Next Boot OS:</td>";
166
    echo "    <td><select name=\"next_boot_osid\">\n";
167
    echo "                <option value=\"\">No OS</option>\n";
168 169
    
    while ($row = mysql_fetch_array($osid_result)) {
170
	$osname = $row[osname];
171 172 173 174 175 176 177
	$osid = $row[osid];
	$pid  = $row[pid];

	echo "<option ";
	if ($next_boot_osid == $osid) {
	    echo "selected ";
	}
178
	echo "value=\"$osid\">$pid - $osname</option>\n";
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
    }
    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";
}
199

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


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

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

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

230 231 232
echo "<p><blockquote><blockquote>
      <ol>
        <li> Node startup command must be a pathname. You may also include
233
                optional arguments.
234 235
        <li> RPMs must be a colon separated list of pathnames.
        <li> Tarballs must be a colon separated list of directory path
236 237
                and tarfile path (eg: /usr/site /foo/fee.tar.gz). The
                directory is where the tarfile should be unpacked.
238 239
      </ol>
      </blockquote></blockquote>\n";
240

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