Skip to content

Commit

Permalink
Fix image pattern for FedoraSecondary provider on s390x
Browse files Browse the repository at this point in the history
Updated the image pattern in FedoraSecondaryImageProvider to match
the available Fedora image file names for the s390x architecture.
This resolves the issue where the vmimage utility could not download
the correct image due to a pattern mismatch.

Reference: avocado-framework#6071
Signed-off-by: Harvey Lynden <hlynden@redhat.com>
  • Loading branch information
harvey0100 committed Dec 10, 2024
1 parent 91752d4 commit 0e7e9e6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions avocado/utils/vmimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ def get_image_url(self):
if self.url_old_images and int(self.version) <= 38:
self.url_versions = self.url_old_images

self.url_images = self.url_versions + "{version}/" + cloud + "/{arch}/images/"
return super().get_image_url()
self.url_images = (
self.url_versions + f"{self.version}/" + cloud + f"/{self.arch}/images/"
)
image_url = super().get_image_url()
return image_url


class FedoraImageProvider(FedoraImageProviderBase):
Expand All @@ -235,7 +238,7 @@ def __init__(self, version="[0-9]+", build="[0-9]+.[0-9]+", arch=DEFAULT_ARCH):
self.url_old_images = (
"https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/"
)
self.image_pattern = "Fedora-Cloud-Base-(?P<version>{version})-(?P<build>{build}).(?P<arch>{arch}).qcow2$"
self.image_pattern = "Fedora-Cloud-Base-Generic-(?P<version>{version})-(?P<build>{build}).(?P<arch>{arch}).qcow2$"


class FedoraSecondaryImageProvider(FedoraImageProviderBase):
Expand All @@ -254,7 +257,7 @@ def __init__(self, version="[0-9]+", build="[0-9]+.[0-9]+", arch=DEFAULT_ARCH):
self.url_old_images = (
"https://archives.fedoraproject.org/pub/archive/fedora-secondary/releases/"
)
self.image_pattern = "Fedora-Cloud-Base-(?P<version>{version})-(?P<build>{build}).(?P<arch>{arch}).qcow2$"
self.image_pattern = "Fedora-Cloud-Base-Generic-(?P<version>{version})-(?P<build>{build}).(?P<arch>{arch}).qcow2$"


class CentOSImageProvider(ImageProviderBase):
Expand Down Expand Up @@ -585,6 +588,7 @@ def download(self):
cache_dirs = [self.cache_dir]
else:
cache_dirs = self.cache_dir
print(f"Attempting to download image from URL: {self.url}")
asset_path = asset.Asset(
name=self.url,
asset_hash=self.checksum,
Expand Down Expand Up @@ -657,6 +661,9 @@ def from_parameters(
:returns: Image instance that can provide the image
according to the parameters.
"""
# Use the current system architecture if arch is not provided
if arch is None:
arch = DEFAULT_ARCH
provider = get_best_provider(name, version, build, arch)

if cache_dir is None:
Expand Down Expand Up @@ -728,11 +735,12 @@ def get_best_provider(name=None, version=None, build=None, arch=None):
for provider in IMAGE_PROVIDERS:
if name is None or name == provider.name.lower():
try:
return provider(**provider_args)
selected_provider = provider(**provider_args)
return selected_provider
except ImageProviderError as e:
LOG.debug(e)
print(f"Error instantiating provider {provider.name}: {e}")

LOG.debug("Provider for %s not available", name)
print(f"Provider for {name} not available")
raise AttributeError("Provider not available")


Expand Down

0 comments on commit 0e7e9e6

Please sign in to comment.