Commit c6430fe1 authored by Leigh Stoller's avatar Leigh Stoller

Move WRITEOSIDMENU() into osiddefs.php3 file for inclusion into other

files. Then use it in the newosid page to allow setting of the
nextosid field (by admin people only). This will make it a tiny tiny bit
easier to set up new testbeds.
parent ba3aff3f
......@@ -242,3 +242,7 @@ function TBvalid_num_ron($token) {
return TBcheck_dbslot($token, "projects", "num_ron",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
}
function TBvalid_osid($token) {
return TBcheck_dbslot($token, "os_info", "osid",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
}
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");
include("osiddefs.php3");
#
# Standard Testbed Header
......@@ -39,39 +40,6 @@ $types_result =
"left join node_types as nt on n.type=nt.type ".
"where nt.imageable=1");
#
# Helper function to write out a menu.
#
function WRITEOSIDMENU($caption, $value, $osid_result, $previous)
{
echo "<tr>
<td>*$caption:</td>";
echo " <td><select name=\"formfields[$value]\">
<option value=X>Please Select </option>\n";
mysql_data_seek($osid_result, 0);
while ($row = mysql_fetch_array($osid_result)) {
$osid = $row[osid];
$osname = $row[osname];
$pid = $row[pid];
$selected = "";
if (strcmp($previous, "$osid") == 0)
$selected = "selected";
echo "<option $selected value='$osid'>$pid - $osname</option>\n";
}
$selected = "";
if (strcmp($previous, "none") == 0)
$selected = "selected";
echo " <option $selected value=none>No OS</option>\n";
echo " </select>";
echo " </td>
</tr>\n";
}
#
# Spit the form out using the array of data.
#
......@@ -314,16 +282,16 @@ function SPITFORM($formfields, $errors)
echo " </td>
</tr>\n";
WRITEOSIDMENU("Partition 1 OS[<b>2</b>]",
"part1_osid", $osid_result, $formfields[part1_osid]);
WRITEOSIDMENU("Partition 2 OS",
"part2_osid", $osid_result, $formfields[part2_osid]);
WRITEOSIDMENU("Partition 3 OS",
"part3_osid", $osid_result, $formfields[part3_osid]);
WRITEOSIDMENU("Partition 4 OS",
"part4_osid", $osid_result, $formfields[part4_osid]);
WRITEOSIDMENU("Boot OS[<b>3</b>]",
"default_osid", $osid_result, $formfields[default_osid]);
WRITEOSIDMENU("Partition 1 OS[<b>2</b>]", "formfields[part1_osid]",
$osid_result, $formfields[part1_osid]);
WRITEOSIDMENU("Partition 2 OS", "formfields[part2_osid]",
$osid_result, $formfields[part2_osid]);
WRITEOSIDMENU("Partition 3 OS", "formfields[part3_osid]",
$osid_result, $formfields[part3_osid]);
WRITEOSIDMENU("Partition 4 OS", "formfields[part4_osid]",
$osid_result, $formfields[part4_osid]);
WRITEOSIDMENU("Boot OS[<b>3</b>]", "formfields[default_osid]",
$osid_result, $formfields[default_osid]);
#
# Path to image.
......
......@@ -185,6 +185,23 @@ elseif (! $osid_opmodes[$OS] && !$isadmin) {
USERERROR("Operational Mode (o_mode) - Not enough permission", 1);
}
# Check nextosid. Only admin users, and only allowed if no version is given.
if (isset($nextosid)) {
if ($nextosid == "" || $nextosid == "none") {
unset($nextosid);
}
elseif (!$isadmin) {
USERERROR("Setting nextosid requires admin mode!", 1);
}
elseif (!TBvalid_osid($nextosid)) {
USERERROR("NextOsid: ". TBFieldErrorString(), 1);
}
elseif (! TBValidOSID($nextosid)) {
USERERROR("NextOsid: $nextosid is not a known osid!", 1);
}
}
#
# And insert the record!
#
......@@ -226,6 +243,10 @@ $query_result =
DBQueryFatal("unlock tables");
if (isset($nextosid)) {
DBQueryFatal("update os_info set nextosid='$nextosid' where osid='$osid'");
}
SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Delete this OS Descriptor",
......
......@@ -29,6 +29,12 @@ if (! count($projlist)) {
"you have permission to create new OS Descriptors!", 1);
}
$osid_result =
DBQueryFatal("select * from os_info ".
"where (path='' or path is NULL) and ".
" version!='' and version is not NULL ".
"order by osid");
?>
<blockquote><blockquote>
Use this page to create a customized Operating System Descriptor,
......@@ -199,6 +205,9 @@ if ($isadmin) {
(no disk reload required)</td>
<td><input type=checkbox name=os_clean value=Yep> Yes</td>
</tr>\n";
WRITEOSIDMENU("NextOsid", "nextosid", $osid_result, "none");
}
echo "<tr>
......
......@@ -32,3 +32,37 @@ $osid_opmodes["MINIMAL"] = 1;
$osid_opmodes["NORMAL"] = 1;
define("TBDB_DEFAULT_OSID_OPMODE", "NORMALv2");
#
# Helper function to write out a menu.
#
function WRITEOSIDMENU($caption, $value, $osid_result, $previous)
{
echo "<tr>
<td>*$caption:</td>";
echo " <td><select name=\"$value\">
<option value=X>Please Select </option>\n";
mysql_data_seek($osid_result, 0);
while ($row = mysql_fetch_array($osid_result)) {
$osid = $row[osid];
$osname = $row[osname];
$pid = $row[pid];
$selected = "";
if (strcmp($previous, "$osid") == 0)
$selected = "selected";
echo "<option $selected value='$osid'>$pid - $osname</option>\n";
}
$selected = "";
if (strcmp($previous, "none") == 0)
$selected = "selected";
echo " <option $selected value=none>No OS</option>\n";
echo " </select>";
echo " </td>
</tr>\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment