Commit 9742eec5 authored by Leigh B Stoller's avatar Leigh B Stoller

Change to previous revision; allow for the image in to be an alias,

and so we have to look through the image versions for each image
in the alias.
parent 25a8780e
#!/usr/bin/perl -wT
#
# Copyright (c) 2007-2017 University of Utah and the Flux Group.
# Copyright (c) 2007-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -1429,6 +1429,7 @@ sub SetRepo($$$$$$)
#
my $owner = $geniuser->uid();
my $command = "cd /local && sudo chmod 777 . && umask 002 && ".
"rm -rf repository && ".
"git clone -n '$repourl' repository && " .
"cd repository && " .
"git config --add core.sharedRepository group && ".
......
......@@ -319,13 +319,33 @@ sub MapToLocalImage($$)
my $image = OSImage->Lookup($ospid, $imagename);
if (defined($image)) {
my @allversions = ();
if ($image->AllVersions(\@allversions) == 0) {
foreach my $im (@allversions) {
if (defined($im->hash()) && exists($blob->{'sha1hash'}) &&
$im->hash() eq $blob->{'sha1hash'}) {
print STDERR "MapToLocalImage: Found local image $im\n";
return $im;
}
#
# This might be an image alias, and on this path it is okay to
# look at all versions of all images to see if we can find one
# with correct hash. Image alias does not export AllVersions,
# cause that generally does not make sense, so we have to do
# it specially here.
#
if ($image->isImageAlias()) {
my $coderef = sub {
my $image = $_[0];
my @tmp = ();
$image->AllVersions(\@tmp);
push(@allversions, @tmp)
if (@tmp);
return 0;
};
$image->ImageIterate($coderef);
}
else {
$image->AllVersions(\@allversions);
}
foreach my $im (@allversions) {
if (defined($im->hash()) && exists($blob->{'sha1hash'}) &&
$im->hash() eq $blob->{'sha1hash'}) {
print STDERR "MapToLocalImage: Found local image $im\n";
return $im;
}
}
}
......
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