nodecontrol_form.php3 8.76 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include_once("node_defs.php");
26 27 28 29

#
# Only known and logged in users can do this.
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33

34
#
35
# Verify page arguments.
36
#
37 38 39 40
$reqargs = RequiredPageArguments("node", PAGEARG_NODE);

# Need these below.
$node_id = $node->node_id();
41 42 43 44

#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
45
#
46 47 48
if (!$isadmin &&
    !$node->AccessCheck($this_user, $TB_NODEACCESS_MODIFYINFO)) {
    USERERROR("You do not have permission to modify node $node_id!", 1);
49 50
}

51 52 53 54 55
#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

56 57 58 59 60 61 62 63 64 65 66
$node_id            = $node->node_id(); 
$type               = $node->type();
$def_boot_osid      = $node->def_boot_osid();
$def_boot_cmd_line  = $node->def_boot_cmd_line();
$next_boot_osid     = $node->next_boot_osid();
$next_boot_cmd_line = $node->next_boot_cmd_line();
$temp_boot_osid     = $node->temp_boot_osid();
$rpms               = $node->rpms();
$tarballs           = $node->tarballs();
$startupcmd         = $node->startupcmd();
$vname              = null;
67 68 69
if ($startupcmd) {
    $startupcmd = htmlspecialchars($startupcmd, ENT_QUOTES);
}
70 71 72 73 74

# Need the reservation info.
if (($resrow = $node->ReservedTableEntry())) {
    $vname = $resrow["vname"];
}
75

76
#
77 78
# 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
79 80 81 82 83 84 85
# paths (which means they are OSKit kernels or BSD MFSes). The list is pruned
# using the pid of the user when not an admin type, of course.
#
# Note the funky "order by", we reverse sort by node_id first to get the
# disk-based OSes up front (node_id is '' for OSKit/MFS kernels).  After
# that we order by pid and then by osname (rather than osid since that is
# now an integer).
86 87
#
if ($isadmin) {
Leigh Stoller's avatar
Leigh Stoller committed
88
    $osid_result =
89
	DBQueryFatal("select o.osname, o.pid, o.osid as oosid, " .
90
		     "   o.vers as overs, " .
91
		     "   p.osid as posid, p.osid_vers as pvers, p.node_id ".
92
		     " from os_info_versions as o ".
93
		     "left join `partitions` as p on o.osid=p.osid ".
94 95
		     "where p.node_id='$node_id' or ".
		     "(o.path!='' and o.path is not NULL) ".
96
		     "order by p.node_id desc,o.pid,o.osname");
97 98
}
else {
99 100
    $uid_idx = $this_user->uid_idx();
    
Leigh Stoller's avatar
Leigh Stoller committed
101
    $osid_result =
102
	DBQueryFatal("select distinct o.osname, o.pid, o.osid as oosid," .
103
		     "   o.vers as overs, " .
104
		     "   p.osid as posid, p.osid_vers as pvers, p.node_id ".
105
		     "from os_info_versions as o ".
106
		     "left join group_membership as m on m.pid=o.pid ".
107
		     "left join `partitions` as p on o.osid=p.osid ".
Leigh Stoller's avatar
Leigh Stoller committed
108
		     "where p.node_id='$node_id' or ".
109
		     "  ((m.uid_idx='$uid_idx' or o.shared=1) and ".
Leigh Stoller's avatar
Leigh Stoller committed
110
		     "   (o.path!='' and o.path is not NULL)) ".
111
		     "order by p.node_id desc,o.pid,o.osname");
112 113
}

114 115 116 117
echo "<table border=2 cellpadding=0 cellspacing=2
       align='center'>\n";

#
118 119 120
# Generate the form.
#
$url = CreateURL("nodecontrol", $node);
121

122
echo "<form action='$url' method=\"post\">\n";
123 124
echo "<tr>
          <td>Node ID:</td>
125
          <td class=\"left\">$node_id</td>
126 127
      </tr>\n";

128 129 130
if ($vname) {
    echo "<tr>
              <td>Virtual Name:</td>
131
              <td class=left>$vname</td>
132 133 134
          </tr>\n";
}

135 136
echo "<tr>
          <td>Node Type:</td>
137
          <td class=\"left\">$type</td>
138 139 140
      </tr>\n";

#
141 142
# OSID, as a menu of those allowed.
#
143
echo "<tr>
144 145
          <td>*Def Boot OS:</td>";
echo "    <td><select name=def_boot_osid>\n";
146
if ($def_boot_osid &&
147
    ($osinfo = $node->def_boot_osinfo())) {
148
    $osname = $osinfo->osname();
149
    $vers = $osinfo->vers();
150
    $pid = $osinfo->pid();
151
    echo "<option selected value='$def_boot_osid:$vers'>$pid - $osname </option>\n";
152
}
153
               while ($row = mysql_fetch_array($osid_result)) {
154 155
                  $osname = $row["osname"];
                  $oosid  = $row["oosid"];
156
                  $overs  = $row["overs"];
157
		  $posid  = $row["posid"];
158
		  $pvers  = $row["pvers"];
159
		  $pid    = $row["pid"];
160

161 162 163 164
		  # Use the osid that came from the partitions table, if there
		  # was one - otherwise, go with the os_info table
		  if ($posid) {
		  	$osid = $posid;
165
			$vers = $pvers;
166 167
		  } else {
		  	$osid = $oosid;
168
			$vers = $overs;
169 170
		  }

171
		  if ($def_boot_osid == $osid) {
172
		      continue;
173
		  }
174
                  echo "<option value='$osid:$vers'>$pid - $osname</option>\n";
175 176
               }
if ($isadmin) {
177
    echo "<option value=\"\">No OS</option>\n";
178 179 180
}
echo "       </select>";
echo "    </td>
181 182 183 184 185 186 187 188 189
      </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";

190 191 192 193
if ($isadmin) {
    mysql_data_seek($osid_result, 0);

    echo "<tr>
194
              <td>Next Boot OS:</td>";
195
    echo "    <td><select name=\"next_boot_osid\">\n";
196
    echo "                <option value=\"\">No OS</option>\n";
197 198
    
    while ($row = mysql_fetch_array($osid_result)) {
199 200
	$osname = $row["osname"];
	$oosid = $row["oosid"];
201
	$overs = $row["overs"];
202
	$posid = $row["posid"];
203
	$pvers = $row["pvers"];
204
	$pid   = $row["pid"];
205 206 207 208 209

        # Use the osid that came from the partitions table, if there
	# was one - otherwise, go with the os_info table
	if ($posid) {
	    $osid = $posid;
210
	    $vers = $pvers;
211 212 213
	}
	else {
	    $osid = $oosid;
214
	    $vers = $overs;
215
	}
216 217 218 219 220

	echo "<option ";
	if ($next_boot_osid == $osid) {
	    echo "selected ";
	}
221
	echo "value='$osid:$vers'>$pid - $osname</option>\n";
222 223 224 225 226 227 228 229 230 231 232
    }
    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";
233 234 235 236 237 238 239 240 241

    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)) {
242 243
	$osname = $row["osname"];
	$oosid = $row["oosid"];
244
	$overs = $row["overs"];
245
	$posid = $row["posid"];
246
	$pvers = $row["pvers"];
247
	$pid   = $row["pid"];
248 249 250 251 252

        # Use the osid that came from the partitions table, if there
	# was one - otherwise, go with the os_info table
	if ($posid) {
	    $osid = $posid;
253
	    $vers = $pvers;
254 255 256
	}
	else {
	    $osid = $oosid;
257
	    $vers = $overs;
258 259 260 261 262 263
	}

	echo "<option ";
	if ($temp_boot_osid == $osid) {
	    echo "selected ";
	}
264
	echo "value='$osid:$vers'>$pid - $osname</option>\n";
265 266 267 268
    }
    echo "       </select>";
    echo "    </td>
           </tr>\n";
269
}
270

271
echo "<tr>
272
          <td>Startup Command[<b>1</b>]:</td>
273 274
          <td class=\"left\">
              <input type=\"text\" name=\"startupcmd\" size=\"60\"
275
                     maxlength=\"256\" value='$startupcmd'></td>
276 277 278
      </tr>\n";


279
echo "<tr>
280
          <td>RPMs[<b>2</b>]:</td>
281 282
          <td class=\"left\">
              <input type=\"text\" name=\"rpms\" size=\"60\"
283
                     maxlength=\"1024\" value=\"$rpms\"></td>
284 285
      </tr>\n";

286
echo "<tr>
287
          <td>Tarballs[<b>3</b>]:</td>
288 289 290 291 292
          <td class=\"left\">
              <input type=\"text\" name=\"tarballs\" size=\"60\"
                     maxlength=\"1024\" value=\"$tarballs\"></td>
      </tr>\n";

293 294 295 296 297 298 299 300
echo "<tr>
          <td colspan=2 align=center>
              <b><input type=\"submit\" value=\"Submit\"></b>
          </td>
     </tr>
     </form>
     </table>\n";

301 302 303
echo "<p><blockquote><blockquote>
      <ol>
        <li> Node startup command must be a pathname. You may also include
304
                optional arguments.
305 306
        <li> RPMs must be a colon separated list of pathnames.
        <li> Tarballs must be a colon separated list of directory path
Leigh Stoller's avatar
Leigh Stoller committed
307
                and tarfile path (/usr/site:/foo/fee.tar.gz). The
308
                directory is where the tarfile should be unpacked.
309 310
      </ol>
      </blockquote></blockquote>\n";
311

312 313 314 315 316
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>