Commit bbf6f1ef authored by Leigh Stoller's avatar Leigh Stoller

Add support for Chad's NS file generator stuff; allow NS file to

passed along as a URL argument.
parent a2c63d31
......@@ -12,6 +12,17 @@ PAGEHEADER("Begin a new Testbed Experiment");
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# See if nsdata was provided. Clear it if an empty string, otherwise
# reencode it.
#
if (isset($nsdata)) {
if (strcmp($nsdata, "") == 0)
unset($nsdata);
else
$nsdata = rawurlencode($nsdata);
}
#
# See what projects the uid can create experiments in. Must be at least one.
#
......@@ -64,9 +75,18 @@ echo "<tr>
</tr>\n";
#
# NS file upload.
#
echo "<tr>
# NS file.
#
if (isset($nsdata)) {
echo "<tr>
<td colspan=2>*Your Auto Generated NS file: &nbsp</td>
<input type=hidden name=nsdata value=$nsdata>
<td><a target=_blank href=spitnsdata.php3?nsdata=$nsdata>
View NS File</a></td>
</tr>\n";
}
else {
echo "<tr>
<td rowspan>*Your NS file: &nbsp</td>
<td rowspan><center>Upload (20K max)<br>
......@@ -83,7 +103,8 @@ echo "<tr>
<br>
<input type=\"text\" name=\"exp_localnsfile\" size=\"50\">
</td>
</tr>\n";
</tr>\n";
}
#
# Expires.
......@@ -180,8 +201,7 @@ echo "<p><blockquote>
<a href='newosid_form.php3'>create the OSID first!</a>
<li> You can view a <a href='showosid_list.php3'> list of OSIDs</a>
that are available for you to use in your NS file.
<li>
You can also view a <a href='showimageid_list.php3'> list of
<li> You can also view a <a href='showimageid_list.php3'> list of
ImageIDs.</a>
</ul>
</blockquote>\n";
......
......@@ -6,7 +6,8 @@ include("defs.php3");
#
PAGEHEADER("Beginning a Testbed Experiment");
$mydebug = 0;
$mydebug = 0;
$delnsfile = 0;
#
# First off, sanity check the form to make sure all the required fields
......@@ -124,6 +125,23 @@ elseif ($specupload) {
$nsfile = $exp_nsfile;
$nonsfile = 0;
}
elseif (isset($nsdata) && strcmp($nsdata, "")) {
#
# The NS file is encoded in the URL. Must create a temp file
# to hold it, and pass through to the backend.
#
# XXX Hard to believe, but there is no equiv of mkstemp in php3.
#
$nsfile = tempnam("/tmp", "$exp_pid-$exp_id.nsfile.");
$delnsfile = 1;
$nonsfile = 0;
if (! ($fp = fopen($nsfile, "w"))) {
TBERROR("Could not create temporary file $nsfile", 1);
}
fwrite($fp, urldecode($nsdata));
fclose($fp);
}
else {
#
# I am going to allow shell experiments to be created (No NS file),
......@@ -299,6 +317,10 @@ $result = exec("$TBSUEXEC_PATH $uid $unix_gid ".
"-p $exp_pid -g $exp_gid -e $exp_id $nsfile",
$output, $retval);
if ($delnsfile) {
unlink($nsfile);
}
if ($retval) {
echo "<br><br><h2>
Setup Failure($retval): Output as follows:
......
<?php
include("defs.php3");
#
# Spit back an NS file to the user. It comes in as an urlencoded argument
# and we send it back as plain text so that user can write it out. This
# is in support of the graphical NS topology editor that fires off an
# experiment directly.
#
#
# See if nsdata was provided.
#
if (!isset($nsdata) ||
strcmp($nsdata, "") == 0) {
PAGEERROR("No NS file provided!");
}
header("Content-Type: text/plain");
echo "$nsdata";
?>
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