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, ...@@ -513,8 +513,14 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, aptforms,
if (window.UPDATED) { if (window.UPDATED) {
initNotifyUpdate(); initNotifyUpdate();
} }
else if (gotscript && window.CLONING) { else if (gotscript) {
sup.ShowModal('#warn_pp_modal'); 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, ...@@ -1090,11 +1096,19 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal, moment, aptforms,
$('#show_xml_modal_button').removeClass("hidden"); $('#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"); sup.ShowModal("#waitwait-modal");
var xmlthing = sup.CallServerMethod(ajaxurl, var xmlthing = sup.CallServerMethod(ajaxurl,
"manage_profile", "manage_profile",
"CheckScript", "CheckScript",
{"script" : script}); {"script" : script,
"pid" : $('#profile_pid').val()});
xmlthing.done(callback); xmlthing.done(callback);
} }
......
...@@ -835,13 +835,14 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -835,13 +835,14 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
var html = var html =
"<table class='table table-condensed border-none'><tbody> " + "<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>" + 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>" + 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>" + 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>"; details.rawstate + "</td></tr>";
if (_.has(details, "execute_state")) { if (_.has(details, "execute_state")) {
...@@ -866,8 +867,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -866,8 +867,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
tag = "Pending"; tag = "Pending";
icon = "button14.svg" icon = "button14.svg"
} }
html += "<tr><td>Startup Service:</td><td>" + html += "<tr><td class='border-none'>Startup Service:</td>" +
tag + "</td></tr>"; "<td class='border-none'>" + tag + "</td></tr>";
$('#' + jacksIDs[node_id] + ' .node .node-status') $('#' + jacksIDs[node_id] + ' .node .node-status')
.css("visibility", "visible"); .css("visibility", "visible");
......
...@@ -343,6 +343,17 @@ function Do_CheckScript() ...@@ -343,6 +343,17 @@ function Do_CheckScript()
} }
elseif (preg_match("/^source tb_compat/m", $ajax_args["script"])) { elseif (preg_match("/^source tb_compat/m", $ajax_args["script"])) {
$command = "webns2rspec"; $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 { else {
SPITAJAX_ERROR(1, "Unknown script type"); SPITAJAX_ERROR(1, "Unknown script type");
......
...@@ -47,6 +47,7 @@ $this_idx = $this_user->uid_idx(); ...@@ -47,6 +47,7 @@ $this_idx = $this_user->uid_idx();
$optargs = OptionalPageArguments("create", PAGEARG_STRING, $optargs = OptionalPageArguments("create", PAGEARG_STRING,
"action", PAGEARG_STRING, "action", PAGEARG_STRING,
"uuid", PAGEARG_STRING, "uuid", PAGEARG_STRING,
"fromexp", PAGEARG_STRING,
"copyuuid", PAGEARG_STRING, "copyuuid", PAGEARG_STRING,
"snapuuid", PAGEARG_STRING, "snapuuid", PAGEARG_STRING,
"finished", PAGEARG_BOOLEAN, "finished", PAGEARG_BOOLEAN,
...@@ -59,7 +60,7 @@ function SPITFORM($formfields, $errors) ...@@ -59,7 +60,7 @@ function SPITFORM($formfields, $errors)
{ {
global $this_user, $projlist, $action, $profile, $DEFAULT_AGGREGATE; global $this_user, $projlist, $action, $profile, $DEFAULT_AGGREGATE;
global $notifyupdate, $notifyclone, $copyuuid, $snapuuid, $am_array; global $notifyupdate, $notifyclone, $copyuuid, $snapuuid, $am_array;
global $ISCLOUD; global $ISCLOUD, $fromexp;
global $version_array, $WITHPUBLISHING; global $version_array, $WITHPUBLISHING;
$viewing = 0; $viewing = 0;
$candelete = 0; $candelete = 0;
...@@ -201,6 +202,9 @@ function SPITFORM($formfields, $errors) ...@@ -201,6 +202,9 @@ function SPITFORM($formfields, $errors)
elseif (isset($snapuuid)) { elseif (isset($snapuuid)) {
echo " window.SNAPUUID = '$snapuuid';\n"; echo " window.SNAPUUID = '$snapuuid';\n";
} }
if (isset($fromexp)) {
echo " window.EXPUUID = '$fromexp';\n";
}
echo "</script>\n"; echo "</script>\n";
echo "<script src='js/lib/jquery-ui.js'></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"; echo "<script src='js/lib/jquery.appendGrid-1.3.1.min.js'></script>\n";
...@@ -409,6 +413,39 @@ if (! isset($create)) { ...@@ -409,6 +413,39 @@ if (! isset($create)) {
$defaults["profile_pid"] = $project; $defaults["profile_pid"] = $project;
} }
$defaults["profile_who"] = "private"; $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); SPITFORM($defaults, $errors);
return; 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