Commit 4f888896 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Some cleanup and improvements to node type display.

parent 33156d45
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # 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. # All rights reserved.
# #
use English; use English;
...@@ -149,6 +149,7 @@ my %xmlfields = ...@@ -149,6 +149,7 @@ my %xmlfields =
"issimnode" => ["issimnode", $SLOT_OPTIONAL], "issimnode" => ["issimnode", $SLOT_OPTIONAL],
"isgeninode" => ["isgeninode", $SLOT_OPTIONAL], "isgeninode" => ["isgeninode", $SLOT_OPTIONAL],
"isfednode" => ["isfednode", $SLOT_OPTIONAL], "isfednode" => ["isfednode", $SLOT_OPTIONAL],
"isswitch" => ["isswitch", $SLOT_OPTIONAL],
# Dynamic attributes with wildcards. # Dynamic attributes with wildcards.
"attr_boolean_*" => ["attr_boolean", $SLOT_OPTIONAL], "attr_boolean_*" => ["attr_boolean", $SLOT_OPTIONAL],
......
<?php <?php
# #
# EMULAB-COPYRIGHT # 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. # All rights reserved.
# #
include("defs.php3"); include("defs.php3");
...@@ -31,6 +31,8 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING, ...@@ -31,6 +31,8 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING,
"new_type", PAGEARG_STRING, "new_type", PAGEARG_STRING,
# Optional if new_type, required if not. # Optional if new_type, required if not.
"node_type", PAGEARG_STRING, "node_type", PAGEARG_STRING,
# Optional if new_type
"node_class", PAGEARG_STRING,
# Attribute creation and deletion. # Attribute creation and deletion.
"deletes", PAGEARG_ARRAY, "deletes", PAGEARG_ARRAY,
...@@ -39,6 +41,7 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING, ...@@ -39,6 +41,7 @@ $optargs = OptionalPageArguments("submit", PAGEARG_STRING,
"newattribute_name", PAGEARG_STRING, "newattribute_name", PAGEARG_STRING,
"newattribute_value", PAGEARG_ANYTHING); "newattribute_value", PAGEARG_ANYTHING);
if (!isset($node_type)) { $node_type = ""; } if (!isset($node_type)) { $node_type = ""; }
if (!isset($node_class)) { $node_class = "pc"; }
if (!isset($attributes)) { $attributes = array(); } if (!isset($attributes)) { $attributes = array(); }
if (!isset($deletes)) { $deletes = array(); } if (!isset($deletes)) { $deletes = array(); }
...@@ -59,6 +62,13 @@ if ($freebsd_mfs == null || $default_image == null || ...@@ -59,6 +62,13 @@ if ($freebsd_mfs == null || $default_image == null ||
} }
# This belongs elsewhere! # This belongs elsewhere!
$initial_switch_attributes = array(
array("attrkey" => "imageable", "attrvalue" => "0",
"attrtype" => "boolean"),
array("attrkey" => "rebootable", "attrvalue" => "0",
"attrtype" => "boolean"),
);
$initial_attributes = array( $initial_attributes = array(
array("attrkey" => "adminmfs_osid", "attrvalue" => $freebsd_mfs->osid(), array("attrkey" => "adminmfs_osid", "attrvalue" => $freebsd_mfs->osid(),
"attrtype" => "integer"), "attrtype" => "integer"),
...@@ -141,13 +151,6 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors) ...@@ -141,13 +151,6 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors)
# #
if (! isset($new_type)) { if (! isset($new_type)) {
PAGEHEADER("Edit Node 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 { else {
PAGEHEADER("Create Node Type"); PAGEHEADER("Create Node Type");
...@@ -303,6 +306,16 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors) ...@@ -303,6 +306,16 @@ function SPITFORM($node_type, $formfields, $attributes, $deletes, $errors)
</td> </td>
</tr>\n"; </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. # Now do attributes.
# #
...@@ -412,11 +425,14 @@ if (isset($new_type)) { ...@@ -412,11 +425,14 @@ if (isset($new_type)) {
# #
# Starting a new node type - give some reasonable defaults # 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, "isremotenode" => 0, "issubnode" => 0,
"isplabdslice" => 0, "isjailed" => 0, "isdynamic" => 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(); $default_attributes = array();
$attribute_types = array(); $attribute_types = array();
$attribute_deletes = array(); $attribute_deletes = array();
...@@ -626,6 +642,11 @@ if (isset($formfields["isfednode"]) && $formfields["isfednode"] != "") { ...@@ -626,6 +642,11 @@ if (isset($formfields["isfednode"]) && $formfields["isfednode"] != "") {
$args["isfednode"] = $formfields["isfednode"]; $args["isfednode"] = $formfields["isfednode"];
} }
# isswitch
if (isset($formfields["isswitch"]) && $formfields["isswitch"] != "") {
$args["isswitch"] = $formfields["isswitch"];
}
# Existing attributes. # Existing attributes.
foreach ($attributes as $attr_key => $attr_val) { foreach ($attributes as $attr_key => $attr_val) {
if (isset($deletes[$attr_key]) && $deletes[$attr_key] == "checked") if (isset($deletes[$attr_key]) && $deletes[$attr_key] == "checked")
......
<?php <?php
# #
# EMULAB-COPYRIGHT # 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. # All rights reserved.
# #
include("defs.php3"); include("defs.php3");
...@@ -334,15 +334,10 @@ if (! strcmp($showtype, "summary")) { ...@@ -334,15 +334,10 @@ if (! strcmp($showtype, "summary")) {
<td align=center>$allfree</td> <td align=center>$allfree</td>
<td align=center>$alltotal</td> <td align=center>$alltotal</td>
</tr>\n"; </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 "</table>\n";
echo "<center><a href=shownodetype_list.php>Node Type List</a></center>";
if ($allunknown > 0) { if ($allunknown > 0) {
echo "<br><font size=-1><b>*</b> - Some nodes ($allunknown) are ". echo "<br><font size=-1><b>*</b> - Some nodes ($allunknown) are ".
"free, but currently in an unallocatable state.</font>"; "free, but currently in an unallocatable state.</font>";
......
<?php <?php
# #
# EMULAB-COPYRIGHT # 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. # All rights reserved.
# #
include("defs.php3"); include("defs.php3");
...@@ -9,8 +9,10 @@ include("imageid_defs.php"); ...@@ -9,8 +9,10 @@ include("imageid_defs.php");
# #
# Anyone can access this info, its a PUBLIC PAGE! # 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. # Sanitize.
if (!preg_match("/^[-\w]+$/", $node_type)) { if (!preg_match("/^[-\w]+$/", $node_type)) {
...@@ -29,24 +31,35 @@ $query_result = ...@@ -29,24 +31,35 @@ $query_result =
if (! mysql_num_rows($query_result) != 0) { if (! mysql_num_rows($query_result) != 0) {
USERERROR("No such node_type $node_type!", 1); USERERROR("No such node_type $node_type!", 1);
} }
$noderow = mysql_fetch_assoc($query_result); $noderow = mysql_fetch_array($query_result);
echo "<font size=+2>". if ($this_user && ISADMIN()) {
"Node Type <b>$node_type</b>". SUBPAGESTART();
"</font>\n"; 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 echo "<table border=2 cellpadding=0 cellspacing=2
align=center>\n"; align=center>\n";
# Stuff from the node types table. # Stuff from the node types table.
$class = $noderow["class"]; $class = $noderow["class"];
$isvirtnode = $noderow["isvirtnode"]; $options = array("isvirtnode",
$isremotenode = $noderow["isremotenode"]; "isdynamic",
"isjailed",
# Grab the attributes for the type. "isremotenode",
$query_result = DBQueryFatal("select * from node_type_attributes ". "issubnode",
"where type='$node_type' ". "isplabdslice",
"order by attrkey"); "isgeninode",
"isfednode",
"isswitch");
echo "<tr> echo "<tr>
<td>Type:</td> <td>Type:</td>
...@@ -58,46 +71,51 @@ echo "<tr> ...@@ -58,46 +71,51 @@ echo "<tr>
<td class=left>$class</td> <td class=left>$class</td>
</tr>\n"; </tr>\n";
if ($isremotenode) { foreach ($options as $option) {
echo "<tr> $value = $noderow[$option];
<td>Remote:</td>
<td class=left>Yes</td>
</tr>\n";
}
if ($isvirtnode) { if ($value) {
echo "<tr> echo "<tr>
<td>Virtual:</td> <td>$option:</td>
<td class=left>Yes</td> <td class=left>Yes</td>
</tr>\n"; </tr>\n";
}
} }
# #
# And now all of the attributes ... # And now all of the attributes ...
# #
while ($row = mysql_fetch_array($query_result)) { # Grab the attributes for the type.
$key = $row["attrkey"]; $query_result = DBQueryFatal("select * from node_type_attributes ".
$val = $row["attrvalue"]; "where type='$node_type' ".
$attrtype = $row["attrtype"]; "order by attrkey");
if (mysql_num_rows($query_result)) {
if ($key == "default_osid" || echo "<tr></tr>\n";
$key == "jail_osid" ||
$key == "delay_osid") { while ($row = mysql_fetch_array($query_result)) {
if ($osinfo = OSinfo::Lookup($val)) { $key = $row["attrkey"];
$val = $osinfo->osname(); $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") {
elseif ($key == "default_imageid") { if ($image = Image::Lookup($val)) {
if ($image = Image::Lookup($val)) { $val = $image->imagename();
$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 "</table>\n";
echo "<td>$key:</td>\n";
echo "<td class=left>$val</td>\n";
echo "</tr>\n";
} }
echo "</table>\n";
# #
# Suck out info for all the nodes of this type. We are going to show # 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