Commit f59066a6 authored by Leigh Stoller's avatar Leigh Stoller

More tweaks to creating a profile from a classic emulab experiment; we want

to run the parser in the context of the project so that image/blockstore
tests are done properly.
parent 0d47056c
......@@ -513,8 +513,14 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, aptforms,
if (window.UPDATED) {
initNotifyUpdate();
}
else if (gotscript && window.CLONING) {
sup.ShowModal('#warn_pp_modal');
else if (gotscript) {
if (window.CLONING) {
sup.ShowModal('#warn_pp_modal');
}
else if (_.has(window, "EXPUUID")) {
modified = true;
checkScript($('#profile_script_textarea').val());
}
}
}
}
......@@ -1090,11 +1096,19 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, aptforms,
$('#show_xml_modal_button').removeClass("hidden");
}
}
/*
* Send along the project if one is selected; only makes sense
* for NS files, which need to do project based checks on a few
* things (images and blockstores being the most important).
* If this is a modification to an existing profile, we still
* have the project name in the same variable.
*/
sup.ShowModal("#waitwait-modal");
var xmlthing = sup.CallServerMethod(ajaxurl,
"manage_profile",
"CheckScript",
{"script" : script});
{"script" : script,
"pid" : $('#profile_pid').val()});
xmlthing.done(callback);
}
......
......@@ -835,13 +835,14 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
var html =
"<table class='table table-condensed border-none'><tbody> " +
"<tr><td>Node:</td><td>" +
"<tr><td class='border-none'>Node:</td><td class='border-none'>" +
details.component_urn + "</td></tr>" +
"<tr><td>ID:</td><td>" +
"<tr><td class='border-none'>ID:</td><td class='border-none'>" +
details.client_id + "</td></tr>" +
"<tr><td>Status:</td><td>" +
"<tr><td class='border-none'>Status:</td><td class='border-none'>" +
details.status + "</td></tr>" +
"<tr><td>Raw State:</td><td>" +
"<tr><td class='border-none'>Raw State:</td>" +
"<td class='border-none'>" +
details.rawstate + "</td></tr>";
if (_.has(details, "execute_state")) {
......@@ -866,8 +867,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
tag = "Pending";
icon = "button14.svg"
}
html += "<tr><td>Startup Service:</td><td>" +
tag + "</td></tr>";
html += "<tr><td class='border-none'>Startup Service:</td>" +
"<td class='border-none'>" + tag + "</td></tr>";
$('#' + jacksIDs[node_id] + ' .node .node-status')
.css("visibility", "visible");
......
......@@ -343,6 +343,17 @@ function Do_CheckScript()
}
elseif (preg_match("/^source tb_compat/m", $ajax_args["script"])) {
$command = "webns2rspec";
#
# We want to parse in the context of the project, so we can do
# project based checks.
#
if (isset($ajax_args["pid"]) && $ajax_args["pid"] != "") {
if (! TBvalid_pid($ajax_args["pid"])) {
SPITAJAX_ERROR(1, "Bad project name");
return;
}
$command .= " -p " . $ajax_args["pid"];
}
}
else {
SPITAJAX_ERROR(1, "Unknown script type");
......
......@@ -47,6 +47,7 @@ $this_idx = $this_user->uid_idx();
$optargs = OptionalPageArguments("create", PAGEARG_STRING,
"action", PAGEARG_STRING,
"uuid", PAGEARG_STRING,
"fromexp", PAGEARG_STRING,
"copyuuid", PAGEARG_STRING,
"snapuuid", PAGEARG_STRING,
"finished", PAGEARG_BOOLEAN,
......@@ -59,7 +60,7 @@ function SPITFORM($formfields, $errors)
{
global $this_user, $projlist, $action, $profile, $DEFAULT_AGGREGATE;
global $notifyupdate, $notifyclone, $copyuuid, $snapuuid, $am_array;
global $ISCLOUD;
global $ISCLOUD, $fromexp;
global $version_array, $WITHPUBLISHING;
$viewing = 0;
$candelete = 0;
......@@ -201,6 +202,9 @@ function SPITFORM($formfields, $errors)
elseif (isset($snapuuid)) {
echo " window.SNAPUUID = '$snapuuid';\n";
}
if (isset($fromexp)) {
echo " window.EXPUUID = '$fromexp';\n";
}
echo "</script>\n";
echo "<script src='js/lib/jquery-ui.js'></script>\n";
echo "<script src='js/lib/jquery.appendGrid-1.3.1.min.js'></script>\n";
......@@ -409,6 +413,39 @@ if (! isset($create)) {
$defaults["profile_pid"] = $project;
}
$defaults["profile_who"] = "private";
#
# If coming from a classic emulab experiment, then do permission checks
# and then use the NS file for the script. Also set the project.
#
if (isset($fromexp) && $fromexp != "") {
$experiment = Experiment::LookupByUUID($fromexp);
if (!$experiment) {
SPITUSERERROR("No such classic emulab experiment!");
}
if (!$experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
SPITUSERERROR("Not enough permission to create a profile from ".
"this classic emulab experiment");
}
$defaults["profile_pid"] = $experiment->pid();
#
# Blech. We want to add an NS statement that sets the description
# since it is not metadata in a profile, it is part of the source.
#
$script = "";
$lines = preg_split("/\n/", $experiment->NSFile());
foreach ($lines as $line) {
$script .= "$line\n";
if (preg_match("/^set\s+(.*)\s+\[new Simulator/",
$line, $matches)) {
$script .= "\$" . $matches[1] . " description \"" .
CleanString($experiment->description()) . "\"\n";
}
}
$defaults["profile_script"] = $script;
}
}
SPITFORM($defaults, $errors);
return;
......
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