Commit f070f698 authored by Leigh B Stoller's avatar Leigh B Stoller

Allow call to ask for the delta image instead of the full image.

parent 48a4dfcd
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# Copyright (c) 2000-2015 University of Utah and the Flux Group. # Copyright (c) 2000-2016 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -34,14 +34,15 @@ use POSIX qw(mktime strftime); ...@@ -34,14 +34,15 @@ use POSIX qw(mktime strftime);
sub usage() sub usage()
{ {
print STDERR print STDERR
"Usage: spewimage [-h] [-t timestamp] -k access_key <imageid>\n". "Usage: spewimage [-h] [-t timestamp] [-e] -k access_key <imageid>\n".
"Spew an image file to a (widearea) node.\n"; "Spew an image file to a (widearea) node.\n";
exit(-1); exit(-1);
} }
my $optlist = "t:k:hsd"; my $optlist = "t:k:hsde";
my $debug = 0; my $debug = 0;
my $headonly = 0; my $headonly = 0;
my $sigfile = 0; my $sigfile = 0;
my $delta = 0;
my $access_key; my $access_key;
my $timestamp; # GM Time. my $timestamp; # GM Time.
...@@ -102,6 +103,9 @@ if (defined($options{"h"})) { ...@@ -102,6 +103,9 @@ if (defined($options{"h"})) {
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 1;
} }
if (defined($options{"e"})) {
$delta = 1;
}
if (defined($options{"s"})) { if (defined($options{"s"})) {
$sigfile = 1; $sigfile = 1;
} }
...@@ -147,8 +151,11 @@ exit(0); ...@@ -147,8 +151,11 @@ exit(0);
# #
sub SpewImage() sub SpewImage()
{ {
my $file = ($sigfile ? my $file = ($delta ?
$image->FullImageSigFile() : $image->FullImageFile()); ($sigfile ?
$image->DeltaImageSigFile() : $image->DeltaImageFile()) :
($sigfile ?
$image->FullImageSigFile() : $image->FullImageFile()));
open(FD, "< $file") open(FD, "< $file")
or fatal("Could not open $file!\n"); or fatal("Could not open $file!\n");
...@@ -212,8 +219,11 @@ sub VerifyImage() ...@@ -212,8 +219,11 @@ sub VerifyImage()
# The current user needs to be able to read the image file and must # The current user needs to be able to read the image file and must
# have provided proper access key. # have provided proper access key.
# #
my $file = ($sigfile ? my $file = ($delta ?
$image->FullImageSigFile() : $image->FullImageFile()); ($sigfile ?
$image->DeltaImageSigFile() : $image->DeltaImageFile()) :
($sigfile ?
$image->FullImageSigFile() : $image->FullImageFile()));
if (! -r $file) { if (! -r $file) {
if ($debug) { if ($debug) {
......
...@@ -54,6 +54,7 @@ if (!isset($_SERVER["SSL_PROTOCOL"])) { ...@@ -54,6 +54,7 @@ if (!isset($_SERVER["SSL_PROTOCOL"])) {
$reqargs = RequiredPageArguments("image", PAGEARG_IMAGE, $reqargs = RequiredPageArguments("image", PAGEARG_IMAGE,
"access_key", PAGEARG_STRING); "access_key", PAGEARG_STRING);
$optargs = OptionalPageArguments("stamp", PAGEARG_INTEGER, $optargs = OptionalPageArguments("stamp", PAGEARG_INTEGER,
"delta", PAGEARG_BOOLEAN,
"sigfile", PAGEARG_BOOLEAN); "sigfile", PAGEARG_BOOLEAN);
# #
...@@ -84,6 +85,7 @@ $access_key = escapeshellarg($access_key); ...@@ -84,6 +85,7 @@ $access_key = escapeshellarg($access_key);
$arg = ""; $arg = "";
$arg .= (isset($stamp) ? "-t " . escapeshellarg($stamp) : ""); $arg .= (isset($stamp) ? "-t " . escapeshellarg($stamp) : "");
$arg .= (isset($sigfile) && $sigfile ? "-s " : ""); $arg .= (isset($sigfile) && $sigfile ? "-s " : "");
$arg .= (isset($delta) && $delta ? "-e " : "");
$group = $image->Group(); $group = $image->Group();
$pid = $group->pid(); $pid = $group->pid();
$unix_gid = $group->unix_gid(); $unix_gid = $group->unix_gid();
......
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