Commit 713919ff authored by Leigh Stoller's avatar Leigh Stoller

More image version fixes.

parent a29a2aef
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -152,6 +152,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field.
my %xmlfields =
# XML Field Name DB slot name Flags Default
("imageid" => ["imageid", $SLOT_REQUIRED],
"version" => ["version", $SLOT_REQUIRED],
# The rest are optional, so we can skip passing ones that are not changing.
"description" => ["description", $SLOT_OPTIONAL],
......@@ -317,7 +318,8 @@ UserError()
# Now do special checks.
#
my $image = Image->Lookup($editimageid_args{"imageid"});
my $image = Image->Lookup($editimageid_args{"imageid"},
$editimageid_args{"version"});
if (!defined($image)) {
UserError("Image: No such image");
}
......
......@@ -40,9 +40,10 @@ sub usage()
" -q Turn on quiet mode\n");
exit(-1);
}
my $optlist = "dq";
my $optlist = "dqf";
my $debug = 0;
my $quiet = 0;
my $force = 0;
#
# Configure variables
......@@ -88,6 +89,9 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"q"})) {
$quiet = 1;
}
if (defined($options{"f"})) {
$force = 1;
}
usage()
if (@ARGV != 1);
my $imageid = $ARGV[0];
......@@ -112,7 +116,7 @@ if (!defined($image)) {
if (!defined($image)) {
fatal("No such image!");
}
if ($image->released()) {
if ($image->released() && !$force) {
fatal("Image is already released! ".
"Maybe you need to provide imageid:version");
}
......@@ -151,7 +155,7 @@ else {
$version0 = $image;
}
if ($version0->path() =~ /^\/usr\/testbed/) {
$copytofile = "/usr/testbed/images/" . basename($version0->path());
$copytofile = "/usr/testbed/images/" . basename($image->path());
$copyfromfile = $image->path();
if ($image->version()) {
$updatepath = 1;
......@@ -183,6 +187,16 @@ if (defined($copytofile)) {
fatal("Failed to update path");
}
}
if (!$quiet) {
print "Running imagevalidate ...\n";
}
system("$IMAGEVALIDATE -u " . ($quiet ? "-q " : "") .
$image->pid() . "," . $image->imagename() . ":" .
$image->version());
if ($?) {
$image->Unlock();
fatal("Failed to validate the image!");
}
}
# Now mark as released.
if ($image->Release()) {
......
......@@ -334,6 +334,7 @@ class Image
# Add these. Maybe caller should do this?
$args["imageid"] = $image->imageid();
$args["version"] = $image->version();
fwrite($fp, "<image>\n");
foreach ($args as $name => $value) {
......
......@@ -71,7 +71,7 @@ SUBPAGESTART();
SUBMENUSTART("More Options");
WRITESUBMENUBUTTON("Edit this Image Descriptor",
"editimageid.php3?imageid=$imageid");
"editimageid.php3?imageid=$imageid&version=$version");
if ($image->GetLogfile()) {
WRITESUBMENUBUTTON("View Log File",
"showimageid.php3?imageid=$imageid&version=$version&showlog=1");
......
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