Add provider image config to statemachine image upload

This adds an extra argument to the provider image upload method
so that it can have access to the provider image configuration
which it may need in order to obtain extra information such as
the architecture.

It also adds the upload number to the image name format so that
we may name image uploads by their number like we do instances.

Change-Id: I0f47b4443d86f021641f315af4b69da26c4713a6
This commit is contained in:
James E. Blair 2022-02-22 13:26:46 -08:00
parent d832d209be
commit 86631344e3
4 changed files with 17 additions and 10 deletions

View File

@ -1068,7 +1068,9 @@ class UploadWorker(BaseWorker):
filename = image.to_path(self._config.images_dir)
ext_image_name = provider.image_name_format.format(
image_name=image_name, timestamp=str(timestamp)
image_name=image_name,
upload_id=upload_id,
timestamp=str(timestamp)
)
self.log.info("Uploading DIB image build %s from %s to %s" %
@ -1087,6 +1089,7 @@ class UploadWorker(BaseWorker):
try:
external_id = manager.uploadImage(
provider_image,
ext_image_name, filename,
image_type=image.extension,
meta=meta,

View File

@ -387,8 +387,8 @@ class AzureAdapter(statemachine.Adapter):
self.provider.location))
return quota_info_from_sku(sku)
def uploadImage(self, image_name, filename, image_format,
metadata, md5, sha256):
def uploadImage(self, provider_image, image_name, filename,
image_format, metadata, md5, sha256):
self.log.debug(f"Uploading image {image_name}")
file_sz = os.path.getsize(filename)
disk_info = {

View File

@ -374,8 +374,8 @@ class OpenStackProvider(Provider, QuotaSupport):
return False
return True
def uploadImage(self, image_name, filename, image_type=None, meta=None,
md5=None, sha256=None):
def uploadImage(self, provider_image, image_name, filename,
image_type=None, meta=None, md5=None, sha256=None):
# configure glance and upload image. Note the meta flags
# are provided as custom glance properties
# NOTE: we have wait=True set here. This is not how we normally

View File

@ -642,11 +642,12 @@ class StateMachineProvider(Provider, QuotaSupport):
# Image handling
def uploadImage(self, image_name, filename, image_type=None, meta=None,
md5=None, sha256=None):
def uploadImage(self, provider_image, image_name, filename,
image_type=None, meta=None, md5=None, sha256=None):
meta = meta.copy()
meta['nodepool_provider_name'] = self.provider.name
return self.adapter.uploadImage(image_name, filename,
return self.adapter.uploadImage(provider_image, image_name,
filename,
image_format=image_type,
metadata=meta, md5=md5,
sha256=sha256)
@ -909,10 +910,13 @@ class Adapter:
# The following methods must be implemented only if image
# management is supported:
def uploadImage(self, image_name, filename, image_format=None,
metadata=None, md5=None, sha256=None):
def uploadImage(self, provider_image, image_name, filename,
image_format=None, metadata=None, md5=None,
sha256=None):
"""Upload the image to the cloud
:param provider_image ProviderImageConfig:
The provider's config for this image
:param image_name str: The name of the image
:param filename str: The path to the local file to be uploaded
:param image_format str: The format of the image (e.g., "qcow")