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