Commit 4f888896 authored by Leigh Stoller's avatar Leigh Stoller

Some cleanup and improvements to node type display.

parent 33156d45
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -149,6 +149,7 @@ my %xmlfields =
"issimnode" => ["issimnode", $SLOT_OPTIONAL],
"isgeninode" => ["isgeninode", $SLOT_OPTIONAL],
"isfednode" => ["isfednode", $SLOT_OPTIONAL],
"isswitch" => ["isswitch", $SLOT_OPTIONAL],
# Dynamic attributes with wildcards.
"attr_boolean_*" => ["attr_boolean", $SLOT_OPTIONAL],
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -31,6 +31,8 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING,
"new_type", PAGEARG_STRING,
# Optional if new_type, required if not.
"node_type", PAGEARG_STRING,
# Optional if new_type
"node_class", PAGEARG_STRING,
# Attribute creation and deletion.
"deletes", PAGEARG_ARRAY,
......@@ -39,6 +41,7 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING,
"newattribute_name", PAGEARG_STRING,
"newattribute_value", PAGEARG_ANYTHING);
if (!isset($node_type)) { $node_type = ""; }
if (!isset($node_class)) { $node_class = "pc"; }
if (!isset($attributes)) { $attributes = array(); }
if (!isset($deletes)) { $deletes = array(); }
......@@ -59,6 +62,13 @@ if ($freebsd_mfs == null || $default_image == null ||
}
# This belongs elsewhere!
$initial_switch_attributes = array(
array("attrkey" => "imageable", "attrvalue" => "0",
"attrtype" => "boolean"),
array("attrkey" => "rebootable", "attrvalue" => "0",
"attrtype" => "boolean"),
);
$initial_attributes = array(
array("attrkey" => "adminmfs_osid", "attrvalue" => $freebsd_mfs->osid(),
"attrtype" => "integer"),
......@@ -141,13 +151,6 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors)
#
if (! isset($new_type)) {
PAGEHEADER("Edit Node Type");
echo "<font size=+2>Node Type <b>".
"<a href='shownodetype.php3?node_type=$node_type'>$node_type
</a></b>\n".
"</font>\n";
echo "<br><br>\n";
}
else {
PAGEHEADER("Create Node Type");
......@@ -303,6 +306,16 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors)
</td>
</tr>\n";
echo "<tr>
<td colspan=2>isswitch:</td>
<td class=left>
<input type=text
name=\"formfields[isswitch]\"
value=\"" . $formfields["isswitch"] . "\"
size=2>
</td>
</tr>\n";
#
# Now do attributes.
#
......@@ -412,11 +425,14 @@ if (isset($new_type)) {
#
# Starting a new node type - give some reasonable defaults
#
$defaults = array("class" => "pc", "isvirtnode" => 0,
$defaults = array("class" => $node_class, "isvirtnode" => 0,
"isremotenode" => 0, "issubnode" => 0,
"isplabdslice" => 0, "isjailed" => 0, "isdynamic" => 0,
"issimnode" => 0, "isgeninode" => 0, "isfednode" => 0);
"issimnode" => 0, "isgeninode" => 0, "isfednode" => 0,
"isswitch" => ($node_class == "switch" ? 1 : 0));
if ($node_class == "switch") {
$initial_attributes = $initial_switch_attributes;
}
$default_attributes = array();
$attribute_types = array();
$attribute_deletes = array();
......@@ -626,6 +642,11 @@ if (isset($formfields["isfednode"]) && $formfields["isfednode"] != "") {
$args["isfednode"] = $formfields["isfednode"];
}
# isswitch
if (isset($formfields["isswitch"]) && $formfields["isswitch"] != "") {
$args["isswitch"] = $formfields["isswitch"];
}
# Existing attributes.
foreach ($attributes as $attr_key => $attr_val) {
if (isset($deletes[$attr_key]) && $deletes[$attr_key] == "checked")
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -334,15 +334,10 @@ if (! strcmp($showtype, "summary")) {
<td align=center>$allfree</td>
<td align=center>$alltotal</td>
</tr>\n";
if ($isadmin) {
# Give admins the option to create a new type
echo "<tr></tr>\n";
echo "<th colspan=3 align=center>
<a href=editnodetype.php3?new_type=1>Create a new type</a>
</th>\n";
}
echo "</table>\n";
echo "<center><a href=shownodetype_list.php>Node Type List</a></center>";
if ($allunknown > 0) {
echo "<br><font size=-1><b>*</b> - Some nodes ($allunknown) are ".
"free, but currently in an unallocatable state.</font>";
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -9,8 +9,10 @@ include("imageid_defs.php");
#
# Anyone can access this info, its a PUBLIC PAGE!
# Get current user if there is one.
#
$reqargs = RequiredPageArguments("node_type", PAGEARG_STRING);
$this_user = CheckLogin($check_status);
$reqargs = RequiredPageArguments("node_type", PAGEARG_STRING);
# Sanitize.
if (!preg_match("/^[-\w]+$/", $node_type)) {
......@@ -29,24 +31,35 @@ $query_result =
if (! mysql_num_rows($query_result) != 0) {
USERERROR("No such node_type $node_type!", 1);
}
$noderow = mysql_fetch_assoc($query_result);
echo "<font size=+2>".
"Node Type <b>$node_type</b>".
"</font>\n";
$noderow = mysql_fetch_array($query_result);
if ($this_user && ISADMIN()) {
SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Edit this type",
"editnodetype.php3?node_type=$node_type");
WRITESUBMENUBUTTON("Create a PC type",
"editnodetype.php3?new_type=1&node_class=pc");
WRITESUBMENUBUTTON("Create a Switch type",
"editnodetype.php3?new_type=1&node_class=switch");
SUBMENUEND();
SUBPAGEEND();
}
echo "<table border=2 cellpadding=0 cellspacing=2
align=center>\n";
# Stuff from the node types table.
$class = $noderow["class"];
$isvirtnode = $noderow["isvirtnode"];
$isremotenode = $noderow["isremotenode"];
# Grab the attributes for the type.
$query_result = DBQueryFatal("select * from node_type_attributes ".
"where type='$node_type' ".
"order by attrkey");
$class = $noderow["class"];
$options = array("isvirtnode",
"isdynamic",
"isjailed",
"isremotenode",
"issubnode",
"isplabdslice",
"isgeninode",
"isfednode",
"isswitch");
echo "<tr>
<td>Type:</td>
......@@ -58,46 +71,51 @@ echo "<tr>
<td class=left>$class</td>
</tr>\n";
if ($isremotenode) {
echo "<tr>
<td>Remote:</td>
<td class=left>Yes</td>
</tr>\n";
}
foreach ($options as $option) {
$value = $noderow[$option];
if ($isvirtnode) {
echo "<tr>
<td>Virtual:</td>
<td class=left>Yes</td>
if ($value) {
echo "<tr>
<td>$option:</td>
<td class=left>Yes</td>
</tr>\n";
}
}
#
# And now all of the attributes ...
#
while ($row = mysql_fetch_array($query_result)) {
$key = $row["attrkey"];
$val = $row["attrvalue"];
$attrtype = $row["attrtype"];
if ($key == "default_osid" ||
$key == "jail_osid" ||
$key == "delay_osid") {
if ($osinfo = OSinfo::Lookup($val)) {
$val = $osinfo->osname();
# Grab the attributes for the type.
$query_result = DBQueryFatal("select * from node_type_attributes ".
"where type='$node_type' ".
"order by attrkey");
if (mysql_num_rows($query_result)) {
echo "<tr></tr>\n";
while ($row = mysql_fetch_array($query_result)) {
$key = $row["attrkey"];
$val = $row["attrvalue"];
$attrtype = $row["attrtype"];
if ($key == "default_osid" ||
$key == "jail_osid" ||
$key == "delay_osid") {
if ($osinfo = OSinfo::Lookup($val)) {
$val = $osinfo->osname();
}
}
}
elseif ($key == "default_imageid") {
if ($image = Image::Lookup($val)) {
$val = $image->imagename();
elseif ($key == "default_imageid") {
if ($image = Image::Lookup($val)) {
$val = $image->imagename();
}
}
echo "<tr>\n";
echo "<td>$key:</td>\n";
echo "<td class=left>$val</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td>$key:</td>\n";
echo "<td class=left>$val</td>\n";
echo "</tr>\n";
echo "</table>\n";
}
echo "</table>\n";
#
# Suck out info for all the nodes of this type. We are going to show
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("table_defs.php");
#
#
# Only known and logged in users allowed.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Standard Testbed Header
#
PAGEHEADER("Image List");
#
# Get the list.
#
$query_result =
DBQueryFatal("select * from node_types order by class,type");
if ($isadmin) {
SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Create a PC type",
"editnodetype.php3?new_type=1&node_class=pc");
WRITESUBMENUBUTTON("Create a Switch type",
"editnodetype.php3?new_type=1&node_class=switch");
SUBMENUEND();
}
echo "<br>";
echo "Note that many types in this list are not accessible to most users";
if ($isadmin) {
SUBPAGEEND();
}
if (mysql_num_rows($query_result)) {
$table = array('#id' => 'nodetypelist',
'#title' => "Node Type List",
'#sortable' => "yes",
'#headings' => array("class" => "Class",
"type" => "Type",
"isvirt" => "IsVirt",
"isrem" => "IsRem",
"isdyn" => "IsDyn",
"isfed" => "IsFed",
"issw" => "IsSwch",
"isjail" => "IsJail"));
$rows = array();
while ($row = mysql_fetch_array($query_result)) {
$type = $row["type"];
$url = "<a href='shownodetype.php3?node_type=$type'>$type</a>";
$tablerow = array("class" => $row["class"],
"type" => $url,
"isvirt" => $row["isvirtnode"],
"isrem" => $row["isremotenode"],
"isdyn" => $row["isdynamic"],
"isfed" => $row["isfednode"],
"issw" => $row["isswitch"],
"isjail" => $row["isjailed"]);
$rows[] = $tablerow;
}
list ($html, $button) = TableRender($table, $rows);
echo $html;
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
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