Skip to content

Commit

Permalink
Prescribe image_source prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Büchse <[email protected]>
  • Loading branch information
mbuechse committed Aug 31, 2023
1 parent 557be32 commit 0457af2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
25 changes: 15 additions & 10 deletions Tests/iaas/scs-0104-v1-images.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
image_groups:
- status: mandatory
list:
- "Ubuntu 22.04"
- "Ubuntu 20.04"
- "Debian 12"
- status: recommended
list:
- "Debian 11"
- "Fedora 38"
images:
- name: "Ubuntu 22.04"
source: https://cloud-images.ubuntu.com/releases/jammy/
status: mandatory
- name: "Kubernetes CAPI 1.27.3"
source: https://minio.services.osism.tech/openstack-k8s-capi-images/ubuntu-2204-kube-v1.27/ubuntu-2204-kube-v1.27.3.qcow2
status: recommended
- name: "Ubuntu 20.04"
source: https://cloud-images.ubuntu.com/releases/focal/
- name: "Debian 12"
source: https://cloud.debian.org/images/cloud/bookworm/
- name: "Debian 11"
source: https://cloud.debian.org/images/cloud/bullseye/
- name: "Debian 10"
source: https://cloud.debian.org/images/cloud/buster/
26 changes: 9 additions & 17 deletions Tests/iaas/standard-images/images-openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,15 @@ def main(argv):
logger.debug("Exception info", exc_info=True)
return 1

if 'image_groups' not in image_data:
logger.critical("Image definition missing 'image_groups' field")
if 'images' not in image_data:
logger.critical("Image definition missing 'images' field")
return 1

# compute union of all image groups, copying group info (mainly "status") to each image
image_specs = []
for image_group in image_data['image_groups']:
group_info = dict(image_group)
group_info.pop('list')
missing = {'status'} - set(group_info)
if missing:
logging.critical(f"Image group missing attributes: {', '.join(missing)}")
return 1
for image_name in image_group['list']:
image_specs.append({"_group": group_info, "name": image_name})

image_specs = image_data['images']
try:
logger.debug(f"Fetching image list from cloud '{cloud}'")
with openstack.connect(cloud=cloud, timeout=32) as conn:
present_images = conn.list_images()
present_images = conn.list_images(show_all=True)
by_name = {
image.name: image
for image in present_images
Expand All @@ -123,10 +112,13 @@ def main(argv):
for image_spec in image_specs:
image = by_name.get(image_spec['name'])
if not image:
status = image_spec['_group']['status']
level = {"mandatory": logging.ERROR}.get(status, logging.INFO)
status = image_spec.get('status', 'optional')
level = {"mandatory": logging.ERROR, "recommended": logging.INFO}.get(status, logging.DEBUG)
logger.log(level, f"Missing {status} image '{image_spec['name']}'")
continue
img_source = image.properties['image_source']
if not img_source.startswith(image_spec['source']):
logger.error(f"Image '{image_spec['name']}' source mismatch: {image_spec['source']} != {img_source} {image.properties}")
except BaseException as e:
logger.critical(f"{e!r}")
logger.debug("Exception info", exc_info=True)
Expand Down

0 comments on commit 0457af2

Please sign in to comment.