Skip to content

Commit a32a69e

Browse files
garloffmbuechse
andcommitted
Add os_purpose field and output info.
Signed-off-by: Kurt Garloff <[email protected]> Co-authored-by: Matthias Büchse <[email protected]>
1 parent e6f9e5a commit a32a69e

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Tests/iaas/openstack_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from scs_0102_image_metadata.image_metadata import \
2525
compute_scs_0102_prop_architecture, compute_scs_0102_prop_hash_algo, compute_scs_0102_prop_min_disk, \
2626
compute_scs_0102_prop_min_ram, compute_scs_0102_prop_os_version, compute_scs_0102_prop_os_distro, \
27+
compute_scs_0102_prop_os_purpose, \
2728
compute_scs_0102_prop_hw_disk_bus, compute_scs_0102_prop_hypervisor_type, compute_scs_0102_prop_hw_rng_model, \
2829
compute_scs_0102_prop_image_build_date, compute_scs_0102_prop_image_original_user, \
2930
compute_scs_0102_prop_image_source, compute_scs_0102_prop_image_description, \
@@ -90,6 +91,7 @@ def make_container(cloud):
9091
c.add_function('scs_0102_prop_min_ram', lambda c: compute_scs_0102_prop_min_ram(c.images))
9192
c.add_function('scs_0102_prop_os_version', lambda c: compute_scs_0102_prop_os_version(c.images))
9293
c.add_function('scs_0102_prop_os_distro', lambda c: compute_scs_0102_prop_os_distro(c.images))
94+
c.add_function('scs_0102_prop_os_purpose', lambda c: compute_scs_0102_prop_os_purpose(c.images))
9395
c.add_function('scs_0102_prop_hw_disk_bus', lambda c: compute_scs_0102_prop_hw_disk_bus(c.images))
9496
c.add_function('scs_0102_prop_hypervisor_type', lambda c: compute_scs_0102_prop_hypervisor_type(c.images))
9597
c.add_function('scs_0102_prop_hw_rng_model', lambda c: compute_scs_0102_prop_hw_rng_model(c.images))

Tests/iaas/scs_0102_image_metadata/image_metadata.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
HW_DISK_BUSES = ("virtio", "scsi", None) # FIXME why None?
1313
HYPERVISOR_TYPES = ("qemu", "kvm", "xen", "hyper-v", "esxi", None)
1414
HW_RNG_MODELS = ("virtio", None)
15-
# Just for nice formatting of image naming hints -- otherwise we capitalize the 1st letter
16-
OS_LIST = ("CentOS", "AlmaLinux", "Windows Server", "RHEL", "SLES", "openSUSE")
15+
OS_PURPOSES = ("generic", "minimal", "k8snode", "gpu", "network", "custom")
1716
# Auxiliary mapping for `freq2secs` (note that values are rounded up a bit on purpose)
1817
FREQ_TO_SEC = {
1918
"never": 0,
@@ -31,15 +30,6 @@
3130
KIB, MIB, GIB = (1024 ** n for n in (1, 2, 3))
3231

3332

34-
def recommended_name(nm, os_list=OS_LIST):
35-
"""Return capitalized name"""
36-
for osnm in os_list:
37-
osln = len(osnm)
38-
if nm[:osln].casefold() == osnm.casefold():
39-
return osnm + nm[osln:]
40-
return nm[0].upper() + nm[1:]
41-
42-
4333
def is_url(stg):
4434
"""Is string stg a URL?"""
4535
idx = stg.find("://")
@@ -156,6 +146,7 @@ def compute_scs_0102_prop_os_version(images):
156146
# NOTE currently we are content when the property is not empty, but we could be more strict,
157147
# because the standard was recently edited to refer to the OpenStack docs, which prescribe
158148
# certain values for common operating systems.
149+
# - os_version not matching regexp r'[0-9\.]*' (should be a numeric version no)
159150
offenders = [img for img in images if not img.os_version]
160151
_log_error('property os_version not set', offenders)
161152
return not offenders
@@ -164,11 +155,20 @@ def compute_scs_0102_prop_os_version(images):
164155
def compute_scs_0102_prop_os_distro(images):
165156
"""This test ensures that each image has a proper value for the property `os_distro`."""
166157
# NOTE see note in `compute_scs_0102_prop_os_version`
158+
# - os_distro not being all-lowercase (they all should be acc. to
159+
# https://docs.openstack.org/glance/2025.1/admin/useful-image-properties.html
167160
offenders = [img for img in images if not img.os_distro]
168161
_log_error('property os_distro not set', offenders)
169162
return not offenders
170163

171164

165+
def compute_scs_0102_prop_os_purpose(images, os_purposes=OS_PURPOSES):
166+
"""This test ensures that each image has a proper value for the property `os_distro`."""
167+
offenders = [img for img in images if img.properties.get('os_purpose') not in os_purposes]
168+
_log_error('property os_purpose not set or not correct', offenders)
169+
return not offenders
170+
171+
172172
def compute_scs_0102_prop_hw_disk_bus(images, hw_disk_buses=HW_DISK_BUSES):
173173
"""This test ensures that each image has a proper value for the property `hw_disk_bus`."""
174174
offenders = [img for img in images if img.hw_disk_bus not in hw_disk_buses]

0 commit comments

Comments
 (0)