Commit b21f4953 authored by Leigh Stoller's avatar Leigh Stoller

Tweaks:

1. Fix for deleting profiles from image deletion; failing to find all
   the profiles to delete.

2. More wording changes.

3. List profile versions and links to them.
parent a8fc4c21
......@@ -83,6 +83,7 @@ use APT_Profile;
# Protos
sub fatal($);
sub UserError($);
sub DoListImages();
sub DoDeleteImage();
......@@ -438,40 +439,54 @@ sub DoDeleteImage()
foreach my $client_id (keys(%irefs)) {
my $imageinfo = $irefs{$client_id};
#
# We do not ever care about system images.
#
next
if ($imageinfo->ospid() eq "emulab-ops");
my $snapname = $profile->name() . "." . $client_id;
next
if (! ($imageinfo->os() eq $profile->name() ||
$imageinfo->os() eq $snapname));
# The image we are trying to delete is okay
if ($imageinfo->image() eq $image_urn) {
$usingimage = 1;
next;
}
else {
my $snapname = $profile->name() . "." . $client_id;
if ($imageinfo->os() eq $profile->name() ||
$imageinfo->os() eq $snapname) {
$conflict = $imageinfo->image();
}
}
if ($usingimage && $conflict) {
fatal("Version " . $version->version() . " of the " .
$version->name() . " profile has another ".
"image that would be deleted as well: $conflict. ".
"You will need to go to the profile page and delete ".
"that profile version before you can delete this image.");
my $mesg =
"Version " . $version->version() . " of the " .
$version->name() . " profile has another ".
"image that would be deleted as well: $conflict. ".
"You will need to go to the profile page and delete ".
"that profile version before you can delete this image.";
if ($webtask) {
$webtask->reason("conflict");
$webtask->profile($version->uuid());
$webtask->image($conflict->image());
}
UserError($mesg);
}
if ($usingimage && $version->isLocked()) {
fatal("Version " . $version->version() . " is locked ".
"down, cannot delete it.");
my $mesg =
"Version " . $version->version() . " of the " .
$version->name() . " profile is locked down, ".
"cannot delete it.";
if ($webtask) {
$webtask->reason("locked");
$webtask->profile($version->uuid());
}
UserError($mesg);
}
if ($usingimage) {
push(@todelete, $version);
print "Would delete profile version " .
$version->version() . "\n";
print "Would delete version " . $version->version() .
" of profile " . $profile->name() . "\n";
}
}
foreach my $version (@todelete) {
......@@ -561,6 +576,18 @@ sub fatal($)
# Exit with negative status so web interface treats it as system error.
exit(-1);
}
sub UserError($)
{
my ($mesg) = @_;
if (defined($webtask)) {
$webtask->output($mesg);
$webtask->Exited(1);
}
print STDERR "$mesg\n";
# Exit with positive status so web interface treats it as user error
exit(1);
}
sub escapeshellarg($)
{
......
......@@ -110,14 +110,24 @@
data-toggle='popover'
data-html='true'
data-delay='{"hide":500}'
data-content='These images are referenced by one
data-content='Some or all versions of
these images are referenced by one
or more versions of a <em>single</em> profile.
Click on the
<span class="glyphicon glyphicon-chevron-right">
</span>
to show the versions that can be deleted.
You may delete these images, but
we will also delete the versions of the profile
that reference the image. You may also edit the
profile so that
it uses a different image, thus freeing up the
image for easier deletion. Note that we will
we will <b>also delete</b> the versions of the
profile
that reference the image, since they will no
longer work after the image is deleted.
You may also edit the profile version(s) that are
using the image, to remove the dependency
(you will need to delete the original version
of the profile after you change it).
<br>
Note that we will
<b>completely</b> remove the image file from the
cluster it resides on, it cannot be recovered.
Profile deletion is permanent as well.'>
......@@ -184,7 +194,16 @@
<%- version.using[0].versions[0].version %>
</a>)
<% } else { %>
(<%- version.using[0].versions.length %> versions)
(Versions
<%
var vlist = [];
_.each(version.using[0].versions, function (profile) {
vlist.push("<a target='_blank' " +
"href='show-profile.php?uuid=" +
profile.uuid + "'>" + profile.version + "</a>");
});
print(vlist.join());
%>)
<% } %>
</tr>
<% }); %>
......
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