Commit e1a430b7 authored by David Johnson's avatar David Johnson
Browse files

Allow users to choose what version of PlanetLab software is running on the

nodes.
parent 0d2f2abc
......@@ -3,7 +3,10 @@
<!--
XML NS template based on planetlab.ns - For making PlanetLab experiments
-->
<nstemplate>
<nstemplate name="PlanetLab Slice">
<description>
Creates a customized PlanetLab slice.
</description>
<variable name="Count" default="10" />
<variable name="ResUsage" default="3" />
<variable name="HWType" default="pcplab" />
......@@ -11,6 +14,7 @@
<variable name="Tarballs" default="/somedir /proj/yourproj/tarfiles/yourtarball.tar.gz" />
<variable name="RPMs" default="/proj/yourproj/rpms/yourrpm.rpm" />
<variable name="Startup" default="/somepath/yourstartupcmd" />
<variable name="NodeVersion" default="Production" />
<nstext>
<section><![CDATA[
# planetlab.ns - NS script to allocate PlanetLab nodes on Emulab/Netbed
......@@ -57,6 +61,7 @@ set num_nodes <Count>
# tb-fix-node $nodeB plab33
#
set hwtype "<HWType>"
set node_version "<NodeVersion>"
#
# Select the N approximately least-loaded nodes of the given type. Fails if
......@@ -73,6 +78,14 @@ for {set i 1} {$i <= $num_nodes} {incr i} {
tb-set-node-failure-action $node($i) "nonfatal"
]]></section>
<section depends_on="NodeVersion" action="comment"><![CDATA[
# Select nodes with a specific software status.
# If you have selected the default, "Production", no desire will be set.
if { $node_version != "Production" } {
$node($i) add-desire "plabstatus-$node_version" 1.0
}
]]></section>
<section><![CDATA[
# Entirely optional stuff; see comments below.
]]></section>
......
......@@ -46,12 +46,29 @@ $plab_type_descr = array('pcplab' => 'Any PlanetLab node',
'pcplabintl' => 'Outside North America',
'pcplabinet2' => 'Internet2');
#
# Grab node versions from the db (currently stored in node_features)
#
$nodeversions = array();
$res = DBQueryFatal("select feature from node_features" .
" where feature like 'plabstatus-%' group by feature");
while ($row = mysql_fetch_row($res)) {
list($foo,$feature) = split("\-",$row[0]);
$nodeversions[] = $feature;
}
if (count($nodeversions) == 0) {
$nodeversions[] = "Production";
}
#
#
# Spit out the form
#
function SPITFORM($advanced,$formfields, $errors = array()) {
global $TBBASE;
global $plab_types, $plab_type_descr;
global $nodeversions;
#
# Default autoswap time - very long...
......@@ -201,6 +218,7 @@ 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";
}
#
......@@ -237,6 +255,25 @@ function SPITFORM($advanced,$formfields, $errors = array()) {
</select>
</td>
</tr>\n";
#
# Node version
#
echo "<tr>
<td><a href=\"$TBBASE/kb-show.php3?xref_tag=plab-node-versions\">Node version</a>:
</td>
<td>
<select name='formfields[nodeversion]'>\n";
foreach ($nodeversions as $nv) {
echo " <option value='$nv'";
if ($formfields["nodeversion"] == $nv) {
echo " selected";
}
echo ">$nv</option>\n";
}
echo " </select>
</td>
</tr>";
#
# Resource usage
......@@ -569,7 +606,10 @@ function MAKENS($formfields) {
}
if ($formfields['startupcmd']) {
$nsgen_args .= "-v Startup='$formfields[startupcmd]' ";
}
}
if ($formfields['nodeversion']) {
$nsgen_args .= "-v NodeVersion='$formfields[nodeversion]' ";
}
#
# Note: We run this as nobody on purpose - this is really dumb, but later
......@@ -586,6 +626,8 @@ function MAKENS($formfields) {
# Check values the user submitted to make sure that they are valid
#
function CHECKFORM($formfields) {
global $nodeversions;
$errors = array();
if (!preg_match("/^\d+$/",$formfields['count'],$matches)) {
$errors['count'] = "Number of nodes must be a positive integer";
......@@ -611,6 +653,10 @@ function CHECKFORM($formfields) {
preg_match("/'/",$formfields['startupcmd'],$matches)) {
$errors['startupcmd'] = "Invalid characters in startup command";
}
if ($formfields['nodeversion'] &&
!in_array($formfields['nodeversion'],$nodeversions)) {
$errors['nodeversion'] = "Invalid node version $formfields[nodeversion]";
}
return $errors;
}
......
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