nodecontrol_form.php3 6.78 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
    $osid_result =
	DBQueryFatal("select o.*,p.osid from os_info as o ".
		     "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 80
    $osid_result =
	DBQueryFatal("select distinct o.*,p.osid from os_info as o ".
81
		     "left join group_membership as m on m.pid=o.pid ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
82
		     "left join partitions as p on o.osid=p.osid ".
83 84
		     "where m.uid='$uid' and (p.node_id='$node_id' or ".
		     " (o.path!='' and o.path is not NULL) and o.shared=1) ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
85
		     "order by o.pid,o.osid");
86 87
}

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

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

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

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

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

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

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

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


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

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

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

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

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


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

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

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

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

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