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

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 #!/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 # {{{EMULAB-LICENSE
# #
...@@ -1429,6 +1429,7 @@ sub SetRepo($$$$$$) ...@@ -1429,6 +1429,7 @@ sub SetRepo($$$$$$)
# #
my $owner = $geniuser->uid(); my $owner = $geniuser->uid();
my $command = "cd /local && sudo chmod 777 . && umask 002 && ". my $command = "cd /local && sudo chmod 777 . && umask 002 && ".
"rm -rf repository && ".
"git clone -n '$repourl' repository && " . "git clone -n '$repourl' repository && " .
"cd repository && " . "cd repository && " .
"git config --add core.sharedRepository group && ". "git config --add core.sharedRepository group && ".
......
...@@ -319,13 +319,33 @@ sub MapToLocalImage($$) ...@@ -319,13 +319,33 @@ sub MapToLocalImage($$)
my $image = OSImage->Lookup($ospid, $imagename); my $image = OSImage->Lookup($ospid, $imagename);
if (defined($image)) { if (defined($image)) {
my @allversions = (); my @allversions = ();
if ($image->AllVersions(\@allversions) == 0) { #
foreach my $im (@allversions) { # This might be an image alias, and on this path it is okay to
if (defined($im->hash()) && exists($blob->{'sha1hash'}) && # look at all versions of all images to see if we can find one
$im->hash() eq $blob->{'sha1hash'}) { # with correct hash. Image alias does not export AllVersions,
print STDERR "MapToLocalImage: Found local image $im\n"; # cause that generally does not make sense, so we have to do
return $im; # 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