Commit 59259db3 authored by Leigh Stoller's avatar Leigh Stoller

Another set of changes for new geni-lib parameters.

* Use an emulabfeature to control what projects use the new ppwizard and
  geni-lib code. The feature is applied to the profile's project, since
  who is instantiating and what project it is instantiated into, does
  not really matter, the incompatible changes are also associated with
  the profile.

* Run both versions of the ppwizard side by side, and flip between them
  when the user is using the profile picker.

* The new version of geni-lib is /usr/testbed/opsdir/lib/geni-lib.new,
  we tell the genilab jail to use that directory when on the new path.

* All of this is temporary.
parent dedc6495
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2015 University of Utah and the Flux Group. # Copyright (c) 2015-2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -115,6 +115,11 @@ my $TBROOT = "@prefix@"; ...@@ -115,6 +115,11 @@ my $TBROOT = "@prefix@";
my $GENILIB = "$TBROOT/lib/geni-lib/"; my $GENILIB = "$TBROOT/lib/geni-lib/";
my $debug = 0; my $debug = 0;
# Watch for this being defined in the calling environment and use that.
if (exists($ENV{"PYTHONPATH"})) {
$GENILIB = $ENV{"PYTHONPATH"};
}
# #
# Turn off line buffering on output # Turn off line buffering on output
# #
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2015-2017 University of Utah and the Flux Group. # Copyright (c) 2015-2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -109,7 +109,12 @@ sub mysystem($); ...@@ -109,7 +109,12 @@ sub mysystem($);
# #
my $TBROOT = "@prefix@"; my $TBROOT = "@prefix@";
my $GENILIB = "$TBROOT/lib/geni-lib/"; my $GENILIB = "$TBROOT/lib/geni-lib/";
my $debug = 0; my $debug = 1;
# Watch for this being defined in the calling environment and use that.
if (exists($ENV{"PYTHONPATH"})) {
$GENILIB = $ENV{"PYTHONPATH"};
}
# #
# Turn off line buffering on output # Turn off line buffering on output
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2018 University of Utah and the Flux Group. # Copyright (c) 2000-2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -58,6 +58,8 @@ my %modifiers = (); ...@@ -58,6 +58,8 @@ my %modifiers = ();
my $rspec; my $rspec;
my $script; my $script;
my $project; my $project;
# Temporary testing.
my $usenewgenilib = 0;
# #
# Configure variables # Configure variables
...@@ -116,6 +118,7 @@ sub ListImages(); ...@@ -116,6 +118,7 @@ sub ListImages();
sub GetScriptParameters($$); sub GetScriptParameters($$);
sub VerifyXML($$); sub VerifyXML($$);
sub ModifyProfileInternal($$$); sub ModifyProfileInternal($$$);
sub UseNewGenilib($);
# The web interface (and in the future the xmlrpc interface) sets this. # The web interface (and in the future the xmlrpc interface) sets this.
my $this_user = User->ImpliedUser(); my $this_user = User->ImpliedUser();
...@@ -277,6 +280,8 @@ sub CreateProfile() ...@@ -277,6 +280,8 @@ sub CreateProfile()
elsif (!$project->AccessCheck($this_user, TB_PROJECT_MAKEIMAGEID())) { elsif (!$project->AccessCheck($this_user, TB_PROJECT_MAKEIMAGEID())) {
UserError({"profile_pid" => "Not enough permission in this project"}); UserError({"profile_pid" => "Not enough permission in this project"});
} }
$usenewgenilib = UseNewGenilib($project);
# Check datasets. # Check datasets.
if (defined($rspec)) { if (defined($rspec)) {
my $errmsg = "Bad dataset"; my $errmsg = "Bad dataset";
...@@ -679,6 +684,7 @@ sub ModifyProfileInternal($$$) ...@@ -679,6 +684,7 @@ sub ModifyProfileInternal($$$)
my ($profile, $project, $pmsg) = @_; my ($profile, $project, $pmsg) = @_;
my %errors = (); my %errors = ();
my $fromrepo = 0; my $fromrepo = 0;
$usenewgenilib = UseNewGenilib($project);
# Check datasets. # Check datasets.
if (defined($rspec)) { if (defined($rspec)) {
...@@ -941,6 +947,7 @@ sub UpdateProfileFromRepo() ...@@ -941,6 +947,7 @@ sub UpdateProfileFromRepo()
print STDERR "Profile is busy, cannot lock it.\n"; print STDERR "Profile is busy, cannot lock it.\n";
exit(1); exit(1);
} }
$usenewgenilib = UseNewGenilib($project);
# #
# We want to update the profile from its URL, and get back the # We want to update the profile from its URL, and get back the
...@@ -970,8 +977,9 @@ sub UpdateProfileFromRepo() ...@@ -970,8 +977,9 @@ sub UpdateProfileFromRepo()
$profile->Unlock(); $profile->Unlock();
fatal("Could not open temporary file for script"); fatal("Could not open temporary file for script");
} }
my $opts = ($usenewgenilib ? "-N" : "");
print $fh $script; print $fh $script;
$output = emutil::ExecQuiet("$RUNGENILIB $filename"); $output = emutil::ExecQuiet("$RUNGENILIB $opts $filename");
if ($?) { if ($?) {
print STDERR $output; print STDERR $output;
$profile->Unlock(); $profile->Unlock();
...@@ -1027,9 +1035,10 @@ sub GetScriptParameters($$) ...@@ -1027,9 +1035,10 @@ sub GetScriptParameters($$)
$$pref = "Could not open temporary file for script"; $$pref = "Could not open temporary file for script";
return -1; return -1;
} }
my $opts = ($usenewgenilib ? "-N" : "");
print $fh $script; print $fh $script;
my $output = emutil::ExecQuiet("$RUNGENILIB -p $filename"); my $output = emutil::ExecQuiet("$RUNGENILIB $opts -p $filename");
if ($?) { if ($?) {
$$pref = $output; $$pref = $output;
return $? >> 8; return $? >> 8;
...@@ -1655,3 +1664,16 @@ sub CanDelete($$) ...@@ -1655,3 +1664,16 @@ sub CanDelete($$)
if ($user->SameUser($project->GetLeader())); if ($user->SameUser($project->GetLeader()));
return 0; return 0;
} }
#
# Should user get new PP code for testing. Use project membership.
#
sub UseNewGenilib($)
{
my ($project) = @_;
return 1
if (EmulabFeatures->FeatureEnabled("NewPParams", undef, $project));
return 0;
}
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# Copyright (c) 2000-2017 University of Utah and the Flux Group. # Copyright (c) 2000-2017, 2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -48,11 +48,12 @@ sub usage() ...@@ -48,11 +48,12 @@ sub usage()
exit(-1); exit(-1);
} }
my $optlist = "do:pP:b:W"; my $optlist = "do:pP:b:WN";
my $debug = 0; my $debug = 0;
my $getparams = 0; my $getparams = 0;
my $paramfile; my $paramfile;
my $ofile; my $ofile;
my $newgenilib = 0;
my $warningsfatal = 0; my $warningsfatal = 0;
# #
...@@ -130,6 +131,9 @@ if (defined($options{"P"})) { ...@@ -130,6 +131,9 @@ if (defined($options{"P"})) {
if (defined($options{"W"})) { if (defined($options{"W"})) {
$warningsfatal = 1; $warningsfatal = 1;
} }
if (defined($options{"N"})) {
$newgenilib = 1;
}
if (defined($options{"b"})) { if (defined($options{"b"})) {
$paramfile = $options{"b"}; $paramfile = $options{"b"};
# Must taint check! # Must taint check!
...@@ -214,6 +218,7 @@ if ($MAINSITE) { ...@@ -214,6 +218,7 @@ if ($MAINSITE) {
$cmdargs .= " -u " . $this_user->uid(); $cmdargs .= " -u " . $this_user->uid();
$cmdargs .= ($getparams ? " -p " : ""); $cmdargs .= ($getparams ? " -p " : "");
$cmdargs .= ($warningsfatal ? " -W " : ""); $cmdargs .= ($warningsfatal ? " -W " : "");
$cmdargs .= ($newgenilib ? " -N " : "");
# #
# We want to send over both files via STDIN, so combine them, and pass # We want to send over both files via STDIN, so combine them, and pass
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2016 University of Utah and the Flux Group. # Copyright (c) 2000-2016, 2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -40,7 +40,7 @@ sub usage() ...@@ -40,7 +40,7 @@ sub usage()
exit(-1); exit(-1);
} }
my $optlist = "u:vpb:WJB:"; my $optlist = "u:vpb:WJB:N";
my $user; my $user;
my $getparams= 0; my $getparams= 0;
my $paramsize; my $paramsize;
...@@ -54,7 +54,7 @@ my $iocagepath; ...@@ -54,7 +54,7 @@ my $iocagepath;
my $TB = "@prefix@"; my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@"; my $TBOPS = "@TBOPSEMAIL@";
my $TESTMODE = 0; my $TESTMODE = 0;
my $GENILIB = "$TB/lib/geni-lib/"; my $GENILIB = "$TB/lib/geni-lib";
my $JAILPROG = "$TB/libexec/genilib-jail"; my $JAILPROG = "$TB/libexec/genilib-jail";
my $TAR = "/usr/bin/tar"; my $TAR = "/usr/bin/tar";
my $debug = 0; my $debug = 0;
...@@ -109,6 +109,10 @@ if (defined($options{"u"})) { ...@@ -109,6 +109,10 @@ if (defined($options{"u"})) {
if (defined($options{"W"})) { if (defined($options{"W"})) {
$warningsfatal = 1; $warningsfatal = 1;
} }
if (defined($options{"N"})) {
$GENILIB .= ".new";
$ENV{"PYTHONPATH"} = $GENILIB;
}
if (defined($options{"J"})) { if (defined($options{"J"})) {
$usejail = 1; $usejail = 1;
if (defined($options{"B"})) { if (defined($options{"B"})) {
......
<?php <?php
# #
# Copyright (c) 2000-2018 University of Utah and the Flux Group. # Copyright (c) 2000-2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -79,6 +79,7 @@ function Do_GetProfile() ...@@ -79,6 +79,7 @@ function Do_GetProfile()
'repohash' => ($profile->repourl() ? 'repohash' => ($profile->repourl() ?
substr($profile->repohash(),0,8) substr($profile->repohash(),0,8)
: ""), : ""),
'newgenilib' => $profile->UseNewGeniLib(),
'amdefault' => $amdefault)); 'amdefault' => $amdefault));
} }
...@@ -894,6 +895,9 @@ function Do_RunScript() ...@@ -894,6 +895,9 @@ function Do_RunScript()
if (preg_match("/^import/m", $script)) { if (preg_match("/^import/m", $script)) {
$command = "webrungenilib"; $command = "webrungenilib";
if (Profile::UseNewGeniLib($this_user)) {
$command .= " -N ";
}
} }
elseif (preg_match("/^source tb_compat/m", $script)) { elseif (preg_match("/^source tb_compat/m", $script)) {
$command = "webns2rspec -a"; $command = "webns2rspec -a";
......
...@@ -534,7 +534,10 @@ if (!isset($create)) { ...@@ -534,7 +534,10 @@ if (!isset($create)) {
SPITFORM($defaults, false, array()); SPITFORM($defaults, false, array());
echo "<div style='display: none'><div id='jacks-dummy'></div></div>\n"; echo "<div style='display: none'><div id='jacks-dummy'></div></div>\n";
AddTemplateList(array("instantiate", "instantiate-new", "aboutapt", "aboutcloudlab", "aboutpnet", "waitwait-modal", "rspectextview-modal", "picker-template","reservation-graph")); AddTemplateList(array("instantiate-new",
"aboutapt", "aboutcloudlab", "aboutpnet",
"waitwait-modal", "rspectextview-modal",
"picker-template","reservation-graph"));
SPITFOOTER(); SPITFOOTER();
return; return;
} }
......
...@@ -40,6 +40,7 @@ $(function () ...@@ -40,6 +40,7 @@ $(function ()
output: null output: null
}; };
var editor = null; var editor = null;
var ppstart = window.ppstartOld;
var loaded_uuid = null; var loaded_uuid = null;
var ppchanged = false; var ppchanged = false;
var monitor = null; var monitor = null;
...@@ -60,7 +61,6 @@ $(function () ...@@ -60,7 +61,6 @@ $(function ()
marked.setOptions({"sanitize" : true}); marked.setOptions({"sanitize" : true});
window.APT_OPTIONS.initialize(sup); window.APT_OPTIONS.initialize(sup);
window.APT_OPTIONS.initialize(ppstart);
registered = window.REGISTERED; registered = window.REGISTERED;
webonly = window.WEBONLY; webonly = window.WEBONLY;
isadmin = window.ISADMIN; isadmin = window.ISADMIN;
...@@ -665,18 +665,12 @@ $(function () ...@@ -665,18 +665,12 @@ $(function ()
cIndex--; cIndex--;
} }
} }
$('#pp_form input').change(function() {
ppchanged = true;
});
$('#pp_form select').change(function() {
ppchanged = true;
});
// TEMPORARY STOPGAP // TEMPORARY STOPGAP
// Refer to Issue #71 // Refer to Issue #71
// https://gitlab.flux.utah.edu/emulab/emulab-devel/issues/71 // https://gitlab.flux.utah.edu/emulab/emulab-devel/issues/71
if ($('#pp_form #hwinfo').length == 0) { if ($('#pp-form #hwinfo').length == 0) {
$('#pp_form input[data-key=osNodeType]').parent().append(''+ $('#pp-form input[data-key=osNodeType]').parent().append(''+
'<a href="' + window.MANUAL + '/hardware.html" style="'+ '<a href="' + window.MANUAL + '/hardware.html" style="'+
'position:absolute;'+ 'position:absolute;'+
'right:21px;'+ 'right:21px;'+
...@@ -1034,6 +1028,7 @@ $(function () ...@@ -1034,6 +1028,7 @@ $(function ()
// form handler pages expect. // form handler pages expect.
var fields = $('.step-forms').serializeArray(); var fields = $('.step-forms').serializeArray();
$.each(fields, function(i, field) { $.each(fields, function(i, field) {
console.info(field, field.name, field.value);
/* /*
* The sites array is special since we want that to be * The sites array is special since we want that to be
* an array inside of the formfields array, and serialize * an array inside of the formfields array, and serialize
...@@ -1051,6 +1046,9 @@ $(function () ...@@ -1051,6 +1046,9 @@ $(function ()
formfields["sites"] = sites; formfields["sites"] = sites;
} }
console.info(formfields); console.info(formfields);
if (! checkonly) {
return;
}
var xmlthing = sup.CallServerMethod(null, "instantiate", var xmlthing = sup.CallServerMethod(null, "instantiate",
(checkonly ? (checkonly ?
"CheckForm" : "Submit"), "CheckForm" : "Submit"),
...@@ -1454,6 +1452,7 @@ $(function () ...@@ -1454,6 +1452,7 @@ $(function ()
function SwitchJacks(which) function SwitchJacks(which)
{ {
console.info("SwitchJacks", which);
if (which == 'small') if (which == 'small')
{ {
$('#stepsContainer #finalize_container') $('#stepsContainer #finalize_container')
...@@ -1653,6 +1652,12 @@ $(function () ...@@ -1653,6 +1652,12 @@ $(function ()
selected_rspec = profile_blob.rspec; selected_rspec = profile_blob.rspec;
selected_version = profile_blob.version; selected_version = profile_blob.version;
amdefault = profile_blob.amdefault; amdefault = profile_blob.amdefault;
if (profile_blob.newgenilib) {
ppstart = window.ppstartNew;
}
else {
ppstart = window.ppstartOld;
}
// Not allowed to copy a repo based profile. // Not allowed to copy a repo based profile.
if (profile_blob.fromrepo) { if (profile_blob.fromrepo) {
...@@ -2494,7 +2499,7 @@ $(function () ...@@ -2494,7 +2499,7 @@ $(function ()
function ClusterSelected(selected, pickered) function ClusterSelected(selected, pickered)
{ {
console.info("ClusterSelected: ", selected); console.info("ClusterSelected: ", selected, pickered);
var cluster = null; var cluster = null;
window.foo = selected; window.foo = selected;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// grey out -/+ and use tooltips to tell people about min/max limits. // grey out -/+ and use tooltips to tell people about min/max limits.
// //
$(function () { $(function () {
window.ppstart = (function() window.ppstartNew = (function()
{ {
'use strict'; 'use strict';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Start a Parameterized Profile // Start a Parameterized Profile
// //
$(function () { $(function () {
window.ppstart = (function() window.ppstartOld = (function()
{ {
'use strict'; 'use strict';
...@@ -739,6 +739,7 @@ $(function () { ...@@ -739,6 +739,7 @@ $(function () {
* the initial values. * the initial values.
*/ */
var callback = function(json) { var callback = function(json) {
console.info("GetParameters", json);
if (json.code) { if (json.code) {
sup.SpitOops("oops", json.value); sup.SpitOops("oops", json.value);
} }
......
...@@ -739,6 +739,9 @@ function Do_CheckScript() ...@@ -739,6 +739,9 @@ function Do_CheckScript()
$command .= " -P $pfname"; $command .= " -P $pfname";
} }
if ($profile->UseNewGeniLib($this_user)) {
$command .= " -N ";
}
} }
elseif (preg_match("/^source tb_compat/m", $ajax_args["script"])) { elseif (preg_match("/^source tb_compat/m", $ajax_args["script"])) {
$command = "webns2rspec"; $command = "webns2rspec";
...@@ -817,9 +820,6 @@ function Do_BindParameters() ...@@ -817,9 +820,6 @@ function Do_BindParameters()
global $DEFAULT_AGGREGATE; global $DEFAULT_AGGREGATE;
global $suexec_output, $suexec_output_array; global $suexec_output, $suexec_output_array;
# Allow for new code path.
$newparams = isset($ajax_args["newparams"]) && $ajax_args["newparams"];
# Allow for form precheck only. So JS code knows it will be fast. # Allow for form precheck only. So JS code knows it will be fast.
$checkonly = isset($ajax_args["checkonly"]) && $ajax_args["checkonly"]; $checkonly = isset($ajax_args["checkonly"]) && $ajax_args["checkonly"];
...@@ -832,6 +832,9 @@ function Do_BindParameters() ...@@ -832,6 +832,9 @@ function Do_BindParameters()
SPITAJAX_ERROR(1, "Unknown profile uuid"); SPITAJAX_ERROR(1, "Unknown profile uuid");
return; return;
} }
# Allow for new code path.
$usenewgenilib = $profile->UseNewGeniLib($this_user);
# Guest users do not run geni-lib; return the rspec or error. # Guest users do not run geni-lib; return the rspec or error.
if (!isset($this_user)) { if (!isset($this_user)) {
if ($profile->rspec() && $profile->rspec() != "") { if ($profile->rspec() && $profile->rspec() != "") {
...@@ -874,7 +877,7 @@ function Do_BindParameters() ...@@ -874,7 +877,7 @@ function Do_BindParameters()
unset($formfields["script"]); unset($formfields["script"]);
unset($formfields["paramdefs"]); unset($formfields["paramdefs"]);
if ($newparams) { if ($usenewgenilib) {
if (Do_CheckFormNew($formfields, $paramdefs, $rval)) { if (Do_CheckFormNew($formfields, $paramdefs, $rval)) {
# Special return value for JS code. # Special return value for JS code.
SPITAJAX_ERROR(2, $rval); SPITAJAX_ERROR(2, $rval);
...@@ -906,7 +909,7 @@ function Do_BindParameters() ...@@ -906,7 +909,7 @@ function Do_BindParameters()
fwrite($fp, $script); fwrite($fp, $script);
fclose($fp); fclose($fp);
$fp = fopen($parmfname, "w"); $fp = fopen($parmfname, "w");
if ($newparams) { if ($usenewgenilib) {
fwrite($fp, json_encode($formfields)); fwrite($fp, json_encode($formfields));
} }
else { else {
...@@ -923,6 +926,7 @@ function Do_BindParameters() ...@@ -923,6 +926,7 @@ function Do_BindParameters()
# #
$retval = SUEXEC($this_uid, "nobody", $retval = SUEXEC($this_uid, "nobody",
"webrungenilib $warningsfatal -b $parmfname ". "webrungenilib $warningsfatal -b $parmfname ".
($usenewgenilib ? " -N " : "") .
" -o $outfname $infname", " -o $outfname $infname",
SUEXEC_ACTION_CONTINUE); SUEXEC_ACTION_CONTINUE);
......
...@@ -765,5 +765,23 @@ class Profile ...@@ -765,5 +765,23 @@ class Profile
return array($finalForm, $defaults); return array($finalForm, $defaults);
} }
#
# Temporary hack to control who gets the new genilib form code.
#
function UseNewGeniLib()
{
# Look to see what project the profile is in, since that determines
# if the profile is being managed on the new geni-lib path.
$project = Project::Lookup($this->pid_idx());
if (!$project) {
return 0;
}
if (FeatureEnabled("NewPParams", null,
$project->DefaultGroup(), null)) {
return 1;
}
return 0;
}
} }
?> ?>
<?php <?php
# #
# Copyright (c) 2000-2016, 2018 University of Utah and the Flux Group. # Copyright (c) 2000-2019 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -231,11 +231,12 @@ function REQUIRE_PPWIZARDSTART() ...@@ -231,11 +231,12 @@ function REQUIRE_PPWIZARDSTART()
REQUIRE_UNDERSCORE(); REQUIRE_UNDERSCORE();
REQUIRE_SUP(); REQUIRE_SUP();
REQUIRE_JACKS_EDITOR(); REQUIRE_JACKS_EDITOR();
AddTemplate("ppform-wizard");
AddTemplate("ppform-wizard-body");
AddTemplate("choose-am"); AddTemplate("choose-am");
AddTemplate("image-picker-modal"); AddTemplate("image-picker-modal");
AddTemplate("ppform-wizard");
AddTemplate("ppform-wizard-body");
AddLibrary("js/ppwizardstart.js"); AddLibrary("js/ppwizardstart.js");
AddLibrary("js/new/ppwizardstart.js");
} }
function REQUIRE_SUP() function REQUIRE_SUP()
......
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