Commit 957e2f6e authored by Leigh Stoller's avatar Leigh Stoller

Add cluster selection to short/long term dataset creation, currently

limited to Emulab and APT.
parent b10f9d1c
......@@ -158,9 +158,9 @@ sub DoCreate()
{
my $usage = sub {
print STDERR "Usage: manage_dataset create ".
"[-t type] [-f fstype] [-e expiration] [-a am_urn] ".
"[-t type] [-f fstype] [-e expiration] ".
"[-R global|project] [-W creator|project] ".
"-s size pid/name\n";
"[-a am_urn] -s size pid/name\n";
exit(-1);
};
my $aggregate_urn = "urn:publicid:IDN+apt.emulab.net+authority+cm";
......@@ -175,7 +175,7 @@ sub DoCreate()
# imdataset snapshot info.
my ($instance,$aggregate,$nodeid,$bsname);
my $optlist = "ds:t:e:f:w:p:R:W:I:i:";
my $optlist = "ds:t:e:f:w:p:R:W:I:i:a:";
my %options = ();
if (! getopts($optlist, \%options)) {
&$usage();
......@@ -183,6 +183,9 @@ sub DoCreate()
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"a"})) {
$aggregate_urn = $options{"a"};
}
if (defined($options{"t"})) {
$type = $options{"t"};
&$usage()
......@@ -213,6 +216,12 @@ sub DoCreate()
}
$aggregate_urn = $aggregate->aggregate_urn();
}
else {
if ($aggregate_urn ne "urn:publicid:IDN+apt.emulab.net+authority+cm" &&
$aggregate_urn ne "urn:publicid:IDN+emulab.net+authority+cm") {
fatal("Invalid cluster selection");
}
}
if (defined($options{"f"})) {
$fstype = $options{"f"};
&$usage()
......@@ -254,7 +263,7 @@ sub DoCreate()
}
&$usage()
if (@ARGV != 1 ||
if (@ARGV != 1 || !defined($aggregate_urn) ||
($type ne "imdataset" && !defined($size)) ||
($type eq "stdataset" && !defined($expires)));
my $name = shift(@ARGV);
......@@ -414,7 +423,7 @@ sub DoDelete()
$errmsg = "DeleteDataset failed: ". $response->output() . "\n";
goto failed;
}
if ($response->code() != GENIRESPONSE_BUSY) {
if ($response->code() == GENIRESPONSE_BUSY) {
$dataset->Unlock();
uerror("dataset was busy at the remote cluster, try again later");
}
......
......@@ -95,6 +95,13 @@ function SPITFORM($formfields, $errors)
echo "<script type='text/plain' id='instances-json'>\n";
echo htmlentities(json_encode($instance_array));
echo "</script>\n";
$amlist = array();
$amlist["urn:publicid:IDN+apt.emulab.net+authority+cm"] = "APT";
$amlist["urn:publicid:IDN+emulab.net+authority+cm"] = "Emulab";
echo "<script type='text/plain' id='amlist-json'>\n";
echo htmlentities(json_encode($amlist));
echo "</script>\n";
}
# FS types.
......
......@@ -40,6 +40,7 @@ function Do_CreateDataSet()
global $ajax_args;
global $DBFieldErrstr, $TBDIR, $APTBASE, $embedded;
global $suexec_output, $suexec_output_array;
global $urn_mapping;
$this_idx = $this_user->uid_idx();
$this_uid = $this_user->uid();
......@@ -128,6 +129,16 @@ function Do_CreateDataSet()
else {
$command .= " -s " . $formfields["dataset_size"];
}
if (! (isset($formfields["dataset_cluster"]) &&
$formfields["dataset_cluster"] != "")) {
$errors["dataset_cluster"] = "Missing field";
}
elseif (!array_key_exists($formfields["dataset_cluster"], $urn_mapping)) {
$errors["dataset_cluster"] = "Illegal value";
}
else {
$command .= " -a '" . $formfields["dataset_cluster"] . "' ";
}
}
else {
#
......@@ -484,8 +495,11 @@ function Do_DeleteDataset()
# Invoke backend.
#
$retval = SUEXEC($this_uid, $dataset->pid(), $command,
SUEXEC_ACTION_CONTINUE);
SUEXEC_ACTION_IGNORE);
if ($retval != 0) {
if ($retval < 0) {
SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
$error = "Transient error; please try again later";
if ($retval && count($suexec_output_array)) {
......@@ -573,8 +587,11 @@ function Do_RefreshDataset()
$retval = SUEXEC($this_uid, $dataset->pid(),
"webmanage_dataset refresh " .
$dataset->pid() . "/" . $dataset->id(),
SUEXEC_ACTION_CONTINUE);
SUEXEC_ACTION_IGNORE);
if ($retval != 0) {
if ($retval < 0) {
SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
$error = "Transient error; please try again later";
if ($retval && count($suexec_output_array)) {
......@@ -628,8 +645,11 @@ function Do_ExtendDataset()
# Invoke backend.
#
$retval = SUEXEC($this_uid, $dataset->pid(), $command,
SUEXEC_ACTION_CONTINUE);
SUEXEC_ACTION_IGNORE);
if ($retval != 0) {
if ($retval < 0) {
SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
$error = "Transient error; please try again later";
if ($retval && count($suexec_output_array)) {
......
......@@ -11,6 +11,7 @@ function (_, sup, moment, mainString, helpString)
var fstypes = null;
var projlist = null;
var instances = null;
var amlist = null;
var editing = false;
var isadmin = false;
var embedded = 0;
......@@ -31,6 +32,9 @@ function (_, sup, moment, mainString, helpString)
if (!embedded) {
instances =
JSON.parse(_.unescape($('#instances-json')[0].textContent));
if ($('#amlist-json').length) {
amlist = JSON.parse(_.unescape($('#amlist-json')[0].textContent));
}
}
GeneratePageBody(fields, null);
}
......@@ -47,6 +51,7 @@ function (_, sup, moment, mainString, helpString)
fstypes: fstypes,
projects: projlist,
instancelist: instances,
amlist: amlist,
title: window.TITLE,
embedded: window.EMBEDDED,
editing: editing,
......@@ -102,18 +107,21 @@ function (_, sup, moment, mainString, helpString)
$('#dataset_expires_div').removeClass("hidden");
$('#dataset_size_div').removeClass("hidden");
$('#dataset_fstype_div').removeClass("hidden");
$('#dataset_cluster_div').removeClass("hidden");
$('#dataset_imageonly_div').addClass("hidden");
}
else if (val == "ltdataset") {
$('#dataset_expires_div').addClass("hidden");
$('#dataset_size_div').removeClass("hidden");
$('#dataset_fstype_div').removeClass("hidden");
$('#dataset_cluster_div').removeClass("hidden");
$('#dataset_imageonly_div').addClass("hidden");
}
else {
$('#dataset_expires_div').addClass("hidden");
$('#dataset_size_div').addClass("hidden");
$('#dataset_fstype_div').addClass("hidden");
$('#dataset_cluster_div').addClass("hidden");
$('#dataset_imageonly_div').removeClass("hidden");
}
});
......
......@@ -103,8 +103,8 @@ function (_, sup, moment, mainString, snapshotString, ShowImagingModal)
* go valid.
*/
if (cansnapshot &&
fields.dataset_state == "busy" ||
fields.dataset_state == "allocating") {
(fields.dataset_state == "busy" ||
fields.dataset_state == "allocating")) {
ShowProgressModal();
}
}
......
......@@ -102,6 +102,30 @@
<% if (editing) { %> readonly <% } %>
type="text">
</div>
<% if (! embedded) { %>
<div id='dataset_cluster_div'
<% if (formfields.dataset_type == "imdataset") {
%> class='hidden' <% } %> >
<% if (! editing) { %>
<select name="dataset_cluster"
id="dataset_cluster"
class='form-control format-me'
data-key="dataset_cluster"
data-label="Cluster"
placeholder='Please Select'>
<option value=''>Please Select</option>
<% _.each(amlist, function(name, value) { %>
<option
<% if (value == formfields.dataset_cluster) { %>
selected
<% } %>
value='<%= value %>'><%= name %>
</option>
<% }); %>
</select>
<% } %>
</div>
<% } %>
<% if (! editing) { %>
<div id='dataset_imageonly_div'
<% if (formfields.dataset_type != "imdataset") {
......
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