Commit 5b2033c3 authored by David Johnson's avatar David Johnson

Fix up things so that we can push node selections based on metrics into

the plab_ez slice create page.  Also fix plab_ez so that submission to
the advanced interface without first browsing to the basic form
generates fewer errors.
parent aa2a90ad
......@@ -15,6 +15,7 @@
<variable name="RPMs" default="/proj/yourproj/rpms/yourrpm.rpm" />
<variable name="Startup" default="/somepath/yourstartupcmd" />
<variable name="NodeVersion" default="Production" />
<variable name="NodeList" default="" />
<nstext>
<section><![CDATA[
# planetlab.ns - NS script to allocate PlanetLab nodes on Emulab/Netbed
......@@ -45,6 +46,14 @@ tb-set-mem-usage <ResUsage>
#
set num_nodes <Count>
#
# Possibly use a fixed set of nodes (if set, overrides num_nodes setting!)
#
set nodelist {<NodeList>}
if { [llength $nodelist] > 0 } {
set num_nodes [llength $nodelist]
}
#
# Type of PlanetLab nodes to request. Current choices, with counts:
# pcplab Any PlanetLab node (127)
......@@ -71,6 +80,10 @@ for {set i 1} {$i <= $num_nodes} {incr i} {
set node($i) [$ns node]
tb-set-hardware $node($i) $hwtype
if { [llength $nodelist] > 0 } {
tb-fix-node $node($i) [lindex $nodelist [expr $i - 1]]
}
]]></section>
<section depends_on="FailOK" action="comment"><![CDATA[
# Allow experiment setup to succeed even if setup of some vnodes fails.
......
......@@ -156,6 +156,16 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
$nnodes = 10;
}
#
# Phys node list
#
if (isset($formfields["nodelist"])) {
$nodelist = $formfields["nodelist"];
}
else {
$nodelist = "";
}
#
# Grab a list of how many are available
#
......@@ -218,7 +228,8 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
echo "<input type='hidden' name='formfields[tarball]' value=''>\n";
echo "<input type='hidden' name='formfields[rpm]' value=''>\n";
echo "<input type='hidden' name='formfields[startupcmd]' value=''>\n";
echo "<input type='hidden' name='formfields[nodeversion]' value='Production'\n";
echo "<input type='hidden' name='formfields[nodeversion]' value='Production'>\n";
echo "<input type='hidden' name='formfields[nodelist]' value=''>\n";
}
#
......@@ -255,7 +266,16 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
</select>
</td>
</tr>\n";
#
# Node list
#
echo "<tr>
<td>Physical Node List:</td>
<td><input type='text' name='formfields[nodelist]'
value='$nodelist' size=36></td>
</tr>\n";
#
# Node version
#
......@@ -266,7 +286,8 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
<select name='formfields[nodeversion]'>\n";
foreach ($nodeversions as $nv) {
echo " <option value='$nv'";
if ($formfields["nodeversion"] == $nv) {
if (array_key_exists("nodeversion",$formfields)
&& $formfields["nodeversion"] == $nv) {
echo " selected";
}
echo ">$nv</option>\n";
......@@ -286,21 +307,26 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
<td>
<select name='formfields[resusage]'>
<option value='5'";
if ($formfields["resusage"] == 5) { echo " selected"; }
if (array_key_exists("resusage",$formfields)
&& $formfields["resusage"] == 5) { echo " selected"; }
echo ">Very High</option>
<option value='4'";
if ($formfields["resusage"] == 4) { echo " selected"; }
if (array_key_exists("resusage",$formfields)
&& $formfields["resusage"] == 4) { echo " selected"; }
echo ">High</option>
<option value='3'";
if (!$formfields["resusage"] || $formfields["resusage"] == 3) {
if (array_key_exists("resusage",$formfields)
&& (!$formfields["resusage"] || $formfields["resusage"] == 3)) {
echo " selected";
}
echo ">Medium</option>
<option value='2'";
if ($formfields["resusage"] == 2) { echo " selected"; }
if (array_key_exists("resusage",$formfields)
&& $formfields["resusage"] == 2) { echo " selected"; }
echo ">Low</option>
<option value='1'";
if ($formfields["resusage"] == 1) { echo " selected"; }
if (array_key_exists("resusage",$formfields)
&& $formfields["resusage"] == 1) { echo " selected"; }
echo ">Very Low</option>
</select>
</td>
......@@ -376,37 +402,49 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
#
# Tarballs
#
$tval = '';
if (array_key_exists("tarball",$formfields)) {
$tval = $formfields["tarball"];
}
echo "<tr>
<td><a href='plab_ez_footnote2.html'
target='emulabfootnote'>Tarball(s)</a> to install:</td>
<td>
<input type='text' size=50 name=formfields[tarball]
value='" . $formfields["tarball"] . "'>
value='" . $tval . "'>
</td>
</tr>\n";
#
# RPMs
#
$tval = '';
if (array_key_exists("rpm",$formfields)) {
$tval = $formfields["rpm"];
}
echo "<tr>
<td><a href='plab_ez_footnote3.html'
target='emulabfootnote'>RPM(s)</a> to install:</td>
<td>
<input type='text' name='formfields[rpm]'
value='" . $formfields["rpm"] . "' size=50>
value='" . $tval . "' size=50>
</td>
</tr>\n";
#
# Startup commands
#
$tval = '';
if (array_key_exists("startupcmd",$formfields)) {
$tval = $formfields["startupcmd"];
}
echo "<tr>
<td><a href='plab_ez_footnote4.html'
target='emulabfootnote'>Command</a> to run on startup:
</td>
<td>
<input type='text' name='formfields[startupcmd]'
value='" . $formfields["startupcmd"] . "' size=50>
value='" . $tval . "' size=50>
</td>
</tr>\n";
} # if ($advanced)
......@@ -589,6 +627,9 @@ function MAKENS($formfields) {
if ($formfields['count']) {
$nsgen_args .= "-v Count='$formfields[count]' ";
}
if ($formfields['nodelist']) {
$nsgen_args .= "-v NodeList='$formfields[nodelist]' ";
}
if ($formfields['type']) {
$nsgen_args .= "-v HWType='$formfields[type]' ";
}
......@@ -632,6 +673,9 @@ function CHECKFORM($formfields) {
if (!preg_match("/^\d+$/",$formfields['count'],$matches)) {
$errors['count'] = "Number of nodes must be a positive integer";
}
if (!preg_match("/(\w+\d+\s*)*/",$formfields['nodelist'],$matches)) {
$errors['nodelist'] = "Node list must be a space-separated list";
}
if ($formfields['when'] && (strcmp($formfields['when'],"never") != 0) &&
(!preg_match("/^\d*(\.\d+)?$/",$formfields['when'],$matches))) {
$errors['when'] = "Auto-terminate time must be a positive decimal " .
......
......@@ -48,7 +48,7 @@ function divinit(id) {
divstate[id].vis = obj.style.visibility;
}
function divflipvis(id) {
function divflipvis(id,linktxtid) {
var obj = document.getElementById(id);
if (!isdef(obj)) {
return false;
......@@ -67,6 +67,17 @@ function divflipvis(id) {
obj.style.position = "static";
divstate[id].vis = obj.style.visibility = "visible";
}
linktxt = "Show";
if (divstate[id].vis == "visible") {
linktxt = "Hide";
}
if (linktxtid != null) {
var lobj = document.getElementById(linktxtid);
if (lobj != null) {
lobj.innerHTML = linktxt;
}
}
}
function init() {
......@@ -122,6 +133,19 @@ function setSelectionAllCheckboxes(form,selstate) {
return true;
}
function getFormElementValue(form,id) {
if (form == null || id == null) {
return '';
}
var fobj = document.forms[form].elements[id];
if (!isdef(fobj)) {
return '';
}
return fobj.value;
}
</script>
<?php
......@@ -608,12 +632,16 @@ function pm_shownondata() {
echo "<tr>\n";
echo "<td class='stealth' valign='top' width='1%'>\n";
SUBMENUSTART("Page Options");
WRITESUBMENUBUTTON("Search Options",
"javascript:divflipvis(\"searchdiv\")");
#WRITESUBMENUBUTTON("Choose Nodes",
#"javascript:divflipvis(\"selectiondiv\")");
WRITESUBMENUBUTTON("Data Legend","#legend");
WRITESUBMENUDIVIDER();
if (!isset($selectable) || !$selectable) {
$url = pm_buildurl(array( 'selectable' => 'yes' ));
WRITESUBMENUBUTTON("Select Nodes",$url);
}
else {
$url = pm_buildurl(array( 'selectable' => 'no' ));
WRITESUBMENUBUTTON("Hide Selection",$url);
}
WRITESUBMENUBUTTON("<span id='searchdivtw'>Hide</span> Search",
"javascript:divflipvis(\"searchdiv\",\"searchdivtw\")");
if (isset($pagelayout) && $pagelayout == 'minimal') {
$url = pm_buildurl(array('pagelayout' => ''));
WRITESUBMENUBUTTON("Show Sidebar",$url);
......@@ -622,6 +650,8 @@ function pm_shownondata() {
$url = pm_buildurl(array('pagelayout' => 'minimal'));
WRITESUBMENUBUTTON("Hide Sidebar",$url);
}
WRITESUBMENUDIVIDER();
WRITESUBMENUBUTTON("Data Legend","#legend");
# Ugh -- cannot use SUBMENUEND cause it inserts a weird <td></td> combo
# SUBMENUEND();
echo " </ul>\n";
......@@ -665,14 +695,30 @@ function pm_showselection() {
}
else {
echo "<textarea name='selectionlist' rows='4' cols='64'>\n";
echo implode(',',$selectionlist);
echo implode(', ',$selectionlist);
echo "</textarea>\n";
echo "<br>\n";
echo "<input type='submit' value='Save Selection Edits'>\n";
echo "<input type='button' value='Clear Selection'>\n";
echo "&nbsp;<input type='button' value='Create PlanetLab Slice from Selection'>\n";
}
echo "</form>\n";
# We need a separate mini-form that submits to plab_ez so that we can
# open a new window without using javascript (only the <form> element
# can accept a target attribute).
echo "<form name='toplabez' id='toplabez' action='plab_ez.php3'" .
" method='post' target='_blank'" .
" onSubmit='setFormElementValue(" .
" \"toplabez\",\"formfields[nodelist]\"," .
" (getFormElementValue(\"nodeeditsel\",\"selectionlist\")).replace(/\\,\s*/g,\" \"))'>\n";
# plab_ez in advanced mode expects to see all these vars.
echo "<input type='hidden' name='formfields[nodelist]' value=''>\n";
echo "<input type='hidden' name='advanced' value='yes'>\n";
# This is a hack. We allow the submit button value to be submitted
# to plab_ez so that plab_ez will figure out that it is supposed to
# be in advanced mode. Before changing the value (name) of this button,
# make sure you understand how plab_ez decides if it is in advanced more.
echo "<input type='submit' name='submit' value='Create PlanetLab Slice'>\n";
echo "</form>\n";
echo "</div>\n";
......@@ -1229,6 +1275,9 @@ function pm_showtable($totalrows,$data) {
global $colsrc,$colcol;
global $selectable,$selectionlist,$newpgsel;
$unicode_up = '&#x25b4;';
$unicode_dn = '&#x25be;';
echo "<center><div style=''>\n";
echo "<p>\n";
echo "<b>$totalrows nodes</b> matched your query.";
......@@ -1273,20 +1322,28 @@ function pm_showtable($totalrows,$data) {
echo " <tr>\n";
if (isset($selectable) && $selectable) {
echo "<th>Select</th>\n";
echo "<th valign='center'>Select</th>\n";
}
foreach ($cols as $c) {
# reverse the sort direction if necessary
$arr = "";
if (isset($sortcols) && count($sortcols) == 1
&& $sortcols[0] == $c) {
$nsortdir = ($sortdir == "asc")?"desc":"asc";
if ($nsortdir == 'desc') {
$arr = " " . $unicode_up;
}
else {
$arr = " " . $unicode_dn;
}
}
else {
$nsortdir = $sortdir;
}
$sstr = "background-color: " . $colcol[$colsrc[$c]];
$url = pm_buildurl(array('sortcols' => $c,'sortdir' => $nsortdir));
echo " <th style='$sstr'><a href='$url'>$c</a></th>\n";
echo " <th valign='center' style='$sstr'>" .
"<a href='$url'>${c}${arr}</a></th>\n";
}
$tmppgsel = array();
......
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