Commit a1056149 authored by Leigh Stoller's avatar Leigh Stoller

Beef up script; add -a (all versions) to deprecate all versions of the

image.
parent a2b64ba9
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -32,18 +32,25 @@ use Data::Dumper;
#
sub usage()
{
print("Usage: deprecate_image [-e|-w] <image> [warning message to users]\n".
print("Usage: deprecate_image [-n] [-e|-w] [-a] <image>".
" [warning message to users]\n".
"Options:\n".
" -a Deprecate all versions of the image.\n".
" -e Use of image is an error; default is warning\n".
" -w Use of image is a warning\n");
" -w Use of image is a warning\n".
" -n Impotent mode\n");
exit(-1);
}
my $optlist = "ewd";
my $optlist = "ewdan";
my $debug = 0;
my $impotent = 0;
my $allvers = 0;
my $doerror = 0;
my $dowarning = 0;
my $deprecated = 0;
my $iserror = 0;
my @imagelist = ();
my $usetracker = 0;
my $message;
#
......@@ -86,6 +93,12 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"n"})) {
$impotent = 1;
}
if (defined($options{"a"})) {
$allvers = 1;
}
if (defined($options{"e"})) {
$doerror = 1;
}
......@@ -97,6 +110,11 @@ usage()
usage()
if ($doerror && $dowarning);
if ($PGENISUPPORT &&
GetSiteVar("protogeni/use_imagetracker")) {
$usetracker = 1;
}
#
# Map invoking user to object.
#
......@@ -123,16 +141,38 @@ elsif ($dowarning) {
if (@ARGV > 1) {
$message = $ARGV[1];
}
$image->Deprecate($message, $iserror) == 0 or
fatal("Could not set deprecation info for image");
if ($allvers) {
if ($image->AllVersions(\@imagelist)) {
fatal("Could not get list of image (versions)");
}
}
else {
@imagelist = ($image);
}
if ($PGENISUPPORT &&
GetSiteVar("protogeni/use_imagetracker")) {
my $imageid = $image->imageid();
print "Posting image $imageid to the image server ...\n";
system("$POSTIMAGEDATA $imageid");
if ($?) {
print STDERR "Could not post alias to the image server\n";
foreach my $image (@imagelist) {
my $versname = $image->versname();
if ($impotent) {
print "Would deprecate $versname\n";
}
else {
$image->Deprecate($message, $iserror) == 0 or
fatal("Could not set deprecation info for image");
}
if ($usetracker && $image->ims_reported()) {
if ($impotent) {
print "Would update $versname at the image server\n";
}
else {
my $imageid = $image->imageid();
print "Updating $versname at the image server ...\n";
system("$POSTIMAGEDATA $versname");
if ($?) {
print STDERR "Could not post to the image server\n";
}
}
}
}
exit(0);
......
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