forked from sig_core/toolkit
utilize dictionaries to pull images
This commit is contained in:
parent
dba0d00e17
commit
7b9db7d547
@ -1357,6 +1357,7 @@ class IsoBuild:
|
|||||||
"""
|
"""
|
||||||
unpack_single_arch = False
|
unpack_single_arch = False
|
||||||
arches_to_unpack = self.arches
|
arches_to_unpack = self.arches
|
||||||
|
latest_artifacts = {}
|
||||||
if self.arch:
|
if self.arch:
|
||||||
unpack_single_arch = True
|
unpack_single_arch = True
|
||||||
arches_to_unpack = [self.arch]
|
arches_to_unpack = [self.arch]
|
||||||
@ -1364,56 +1365,76 @@ class IsoBuild:
|
|||||||
for name, extra in self.cloudimages['images'].items():
|
for name, extra in self.cloudimages['images'].items():
|
||||||
self.log.info(Color.INFO + 'Determining the latest images for ' + name + ' ...')
|
self.log.info(Color.INFO + 'Determining the latest images for ' + name + ' ...')
|
||||||
formattype = extra['format']
|
formattype = extra['format']
|
||||||
|
latest_artifacts[name] = {}
|
||||||
|
primary_variant = extra['primary_variant'] if 'primary_variant' in extra else None
|
||||||
|
latest_artifacts[name]['primary'] = primary_variant
|
||||||
|
|
||||||
variants = extra['variants'] if 'variants' in extra.keys() else [None] # need to loop once
|
variants = extra['variants'] if 'variants' in extra.keys() else [None] # need to loop once
|
||||||
imagename = name
|
imagename = name
|
||||||
primary_variant = extra['primary_variant'] if 'primary_variant' in extra else None
|
variantname = name
|
||||||
latest_artifacts = []
|
|
||||||
|
|
||||||
for variant in variants:
|
for variant in variants:
|
||||||
if variant:
|
if variant:
|
||||||
name = f"{name}-{variant}"
|
variantname = f"{name}-{variant}"
|
||||||
|
self.log.info(Color.INFO + 'Getting latest for variant ' + variant + ' ...')
|
||||||
if self.s3:
|
if self.s3:
|
||||||
latest_artifacts.append(Shared.s3_determine_latest(
|
latest_artifacts[name][variantname] = Shared.s3_determine_latest(
|
||||||
self.s3_bucket,
|
self.s3_bucket,
|
||||||
self.release,
|
self.release,
|
||||||
arches_to_unpack,
|
arches_to_unpack,
|
||||||
formattype,
|
formattype,
|
||||||
name,
|
variantname,
|
||||||
self.log
|
self.log
|
||||||
))
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
latest_artifacts.append(Shared.reqs_determine_latest(
|
latest_artifacts[name][variantname] = Shared.reqs_determine_latest(
|
||||||
self.s3_bucket_url,
|
self.s3_bucket_url,
|
||||||
self.release,
|
self.release,
|
||||||
arches_to_unpack,
|
arches_to_unpack,
|
||||||
formattype,
|
formattype,
|
||||||
name,
|
variantname,
|
||||||
self.log
|
self.log
|
||||||
))
|
)
|
||||||
|
|
||||||
# latest_artifacts should have at least 1 result if has_variants, else == 1
|
# latest_artifacts should have at least 1 result if has_variants, else == 1
|
||||||
|
if not len(latest_artifacts[name][variantname]) > 0:
|
||||||
|
self.log.warn(Color.WARN + 'No images found for ' + variantname +
|
||||||
|
'. This means it will be skipped.')
|
||||||
|
|
||||||
if not len(latest_artifacts) > 0:
|
del imagename
|
||||||
self.log.warn(Color.WARN + 'No images found.')
|
del variantname
|
||||||
|
del variants
|
||||||
|
|
||||||
|
#print(latest_artifacts)
|
||||||
|
for keyname in latest_artifacts.keys():
|
||||||
|
primary = latest_artifacts[keyname]['primary']
|
||||||
|
for imgname in latest_artifacts[keyname]:
|
||||||
|
keysect = latest_artifacts[keyname][imgname]
|
||||||
|
if imgname == 'primary':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.log.info(Color.INFO + 'Attempting to download requested artifacts')
|
if not keysect:
|
||||||
for item in latest_artifacts:
|
continue
|
||||||
|
|
||||||
|
self.log.info(Color.INFO + 'Attempting to download requested ' +
|
||||||
|
'artifacts (' + keyname + ')')
|
||||||
|
|
||||||
for arch in arches_to_unpack:
|
for arch in arches_to_unpack:
|
||||||
image_arch_dir = os.path.join(
|
image_arch_dir = os.path.join(
|
||||||
self.image_work_dir,
|
self.image_work_dir,
|
||||||
arch
|
arch
|
||||||
)
|
)
|
||||||
|
|
||||||
if arch not in item.keys():
|
source_path = keysect[arch]
|
||||||
self.log.warn(Color.WARN + 'Artifact for ' + name +
|
|
||||||
' ' + arch + ' (' + formattype + ') does not exist.')
|
|
||||||
continue
|
|
||||||
|
|
||||||
source_path = item[arch]
|
|
||||||
drop_name = source_path.split('/')[-1]
|
drop_name = source_path.split('/')[-1]
|
||||||
|
|
||||||
|
# Docker containers get a "layer" name, this hack gets
|
||||||
|
# around it. I didn't feel like adding another config opt.
|
||||||
|
if 'layer' in drop_name:
|
||||||
|
fsuffix = drop_name.replace('layer', '')
|
||||||
|
drop_name = source_path.split('/')[-3] + fsuffix
|
||||||
|
|
||||||
checksum_name = drop_name + '.CHECKSUM'
|
checksum_name = drop_name + '.CHECKSUM'
|
||||||
full_drop = '{}/{}'.format(
|
full_drop = '{}/{}'.format(
|
||||||
image_arch_dir,
|
image_arch_dir,
|
||||||
@ -1460,7 +1481,7 @@ class IsoBuild:
|
|||||||
image_arch_dir,
|
image_arch_dir,
|
||||||
self.shortname,
|
self.shortname,
|
||||||
self.major_version,
|
self.major_version,
|
||||||
name,
|
imgname,
|
||||||
arch,
|
arch,
|
||||||
formattype
|
formattype
|
||||||
)
|
)
|
||||||
@ -1469,28 +1490,10 @@ class IsoBuild:
|
|||||||
image_arch_dir,
|
image_arch_dir,
|
||||||
self.shortname,
|
self.shortname,
|
||||||
self.major_version,
|
self.major_version,
|
||||||
name,
|
imgname,
|
||||||
arch,
|
arch,
|
||||||
formattype
|
formattype
|
||||||
)
|
)
|
||||||
# If an image is the primary, we set this.
|
|
||||||
latest_primary_name = '{}/{}-{}-{}.latest.{}.{}'.format(
|
|
||||||
image_arch_dir,
|
|
||||||
self.shortname,
|
|
||||||
self.major_version,
|
|
||||||
imagename,
|
|
||||||
arch,
|
|
||||||
formattype
|
|
||||||
)
|
|
||||||
latest_primary_checksum = '{}/{}-{}-{}.latest.{}.{}.CHECKSUM'.format(
|
|
||||||
image_arch_dir,
|
|
||||||
self.shortname,
|
|
||||||
self.major_version,
|
|
||||||
imagename,
|
|
||||||
arch,
|
|
||||||
formattype
|
|
||||||
)
|
|
||||||
latest_primary_path = latest_name.split('/')[-1]
|
|
||||||
# For some reason python doesn't have a "yeah just change this
|
# For some reason python doesn't have a "yeah just change this
|
||||||
# link" part of the function
|
# link" part of the function
|
||||||
if os.path.exists(latest_name):
|
if os.path.exists(latest_name):
|
||||||
@ -1511,7 +1514,26 @@ class IsoBuild:
|
|||||||
|
|
||||||
# If this is the primary image, set the appropriate symlink
|
# If this is the primary image, set the appropriate symlink
|
||||||
# and checksum
|
# and checksum
|
||||||
if primary_variant and primary_variant in drop_name:
|
if primary and primary in drop_name:
|
||||||
|
# If an image is the primary, we set this.
|
||||||
|
latest_primary_name = '{}/{}-{}-{}.latest.{}.{}'.format(
|
||||||
|
image_arch_dir,
|
||||||
|
self.shortname,
|
||||||
|
self.major_version,
|
||||||
|
keyname,
|
||||||
|
arch,
|
||||||
|
formattype
|
||||||
|
)
|
||||||
|
latest_primary_checksum = '{}/{}-{}-{}.latest.{}.{}.CHECKSUM'.format(
|
||||||
|
image_arch_dir,
|
||||||
|
self.shortname,
|
||||||
|
self.major_version,
|
||||||
|
keyname,
|
||||||
|
arch,
|
||||||
|
formattype
|
||||||
|
)
|
||||||
|
latest_primary_path = latest_name.split('/')[-1]
|
||||||
|
|
||||||
self.log.info('This is the primary image, setting link and checksum')
|
self.log.info('This is the primary image, setting link and checksum')
|
||||||
if os.path.exists(latest_primary_name):
|
if os.path.exists(latest_primary_name):
|
||||||
os.remove(latest_primary_name)
|
os.remove(latest_primary_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user