Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 13 additions & 61 deletions Tests/iaas/flavor-naming/flavor-names-openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def main(argv):
fnmck = flavor_names.CompatLayer()
cloud = None
verbose = False
v3mode = False
accept_old_mand = False
scsMandFile = fnmck.mandFlavorFile

try:
cloud = os.environ["OS_CLOUD"]
Expand All @@ -67,16 +64,17 @@ def main(argv):
elif opt[0] == "-c" or opt[0] == "--os-cloud":
cloud = opt[1]
elif opt[0] == "-C" or opt[0] == "--mand":
scsMandFile = opt[1]
if opt[1].split('/')[-1] != 'scs-0100-v3-flavors.yaml':
print(f'ignoring obsolete argument: {opt[0]}', file=sys.stderr)
elif opt[0] == "-3" or opt[0] == "--v3":
# fnmck.disallow_old = True
v3mode = True
print(f'ignoring obsolete argument: {opt[0]}', file=sys.stderr)
elif opt[0] == "-2" or opt[0] == "--v2plus":
fnmck.disallow_old = True
elif opt[0] == "-1" or opt[0] == "--v1prefer":
fnmck.prefer_old = True
print(f'ignoring obsolete argument: {opt[0]}', file=sys.stderr)
elif opt[0] == "-o" or opt[0] == "--accept-old-mandatory":
accept_old_mand = True
print(f'ignoring obsolete argument: {opt[0]}', file=sys.stderr)
elif opt[0] == "-v" or opt[0] == "--verbose":
verbose = True
elif opt[0] == "-q" or opt[0] == "--quiet":
Expand All @@ -87,17 +85,13 @@ def main(argv):
print(f"CRITICAL: Extra arguments {str(args)}", file=sys.stderr)
usage(1)

scsMandatory, scsRecommended = fnmck.readflavors(scsMandFile, v3mode)

if not cloud:
print("CRITICAL: You need to have OS_CLOUD set or pass --os-cloud=CLOUD.", file=sys.stderr)
sys.exit(1)
conn = openstack.connect(cloud=cloud, timeout=32)
flavors = conn.compute.flavors()

# Lists of flavors: mandatory, good-SCS, bad-SCS, non-SCS, with-warnings
MSCSFlv = []
RSCSFlv = []
SCSFlv = []
wrongFlv = []
nonSCSFlv = []
Expand Down Expand Up @@ -171,77 +165,35 @@ def main(argv):
wrongFlv.append(flv.name)
errors += 1
else:
if flv.name in scsMandatory:
scsMandatory.remove(flv.name)
MSCSFlv.append(flv.name)
elif flv.name in scsRecommended:
scsRecommended.remove(flv.name)
RSCSFlv.append(flv.name)
elif accept_old_mand and fnmck.old_to_new(flv.name) in scsMandatory:
scsMandatory.remove(fnmck.old_to_new(flv.name))
MSCSFlv.append(flv.name) # fnmck.old_to_new(flv.name)
elif accept_old_mand and fnmck.old_to_new(flv.name) in scsRecommended:
scsRecommended.remove(fnmck.old_to_new(flv.name))
RSCSFlv.append(flv.name) # fnmck.old_to_new(flv.name)
else:
SCSFlv.append(flv.name)
SCSFlv.append(flv.name)
if warn:
warnFlv.append(flv.name)
# This makes the output more readable
MSCSFlv.sort()
RSCSFlv.sort()
SCSFlv.sort()
nonSCSFlv.sort()
wrongFlv.sort()
warnFlv.sort()
# We have counted errors on the fly, add missing flavors to the final result
for fn in scsMandatory:
errors += 1
print(f"ERROR: Missing mandatory flavor: {fn}", file=sys.stderr)
# Produce dicts for YAML reporting
flvSCSList = {
"MandatoryFlavorsPresent": MSCSFlv,
"MandatoryFlavorsMissing": scsMandatory,
}
if v3mode:
flvSCSList.update({
"RecommendedFlavorsPresent": RSCSFlv,
"RecommendedFlavorsMissing": scsRecommended,
})
flvSCSList.update({
"OptionalFlavorsValid": SCSFlv,
"OptionalFlavorsWrong": wrongFlv,
"SCSFlavorsValid": SCSFlv,
"SCSFlavorsWrong": wrongFlv,
"FlavorsWithWarnings": warnFlv,
})
}
flvOthList = {
"OtherFlavors": nonSCSFlv
}
flvSCSRep = {
"TotalAmount": len(MSCSFlv) + len(SCSFlv) + len(wrongFlv),
}
# skip the following if no mandatory flavors are given (useful for v3.2 onward)
if len(MSCSFlv) + len(scsMandatory):
flvSCSRep.update({
"MandatoryFlavorsPresent": len(MSCSFlv),
"MandatoryFlavorsMissing": len(scsMandatory),
})
# skip the following if no recommended flavors are given (useful for v1, v2, and v3.2 onward)
if len(RSCSFlv) + len(scsRecommended):
flvSCSRep.update({
"RecommendedFlavorsPresent": len(RSCSFlv),
"RecommendedFlavorsMissing": len(scsRecommended),
})
flvSCSRep.update({
"FlavorsValid": len(SCSFlv) + len(MSCSFlv) + len(RSCSFlv),
"TotalAmount": len(SCSFlv) + len(wrongFlv),
"FlavorsValid": len(SCSFlv),
"FlavorsWrong": len(wrongFlv),
"FlavorsWithWarnings": len(warnFlv),
})
}
flvOthRep = {
"TotalAmount": len(nonSCSFlv),
}
totSummary = {
"Errors": errors,
"Warnings": len(warnFlv)+len(scsRecommended),
"Warnings": len(warnFlv),
}
Report = {cloud: {"TotalSummary": totSummary}}
if not fnmck.quiet:
Expand Down
35 changes: 2 additions & 33 deletions Tests/iaas/flavor-naming/flavor_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from pathlib import Path
from typing import Optional

import yaml


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -757,9 +755,7 @@ def __init__(self):
self.debug = False
self.quiet = False
self.disallow_old = False
self.prefer_old = False
self.v3_flv = False
self.mandFlavorFile = str(Path(HERE.parent, "SCS-Spec.MandatoryFlavors.yaml"))
bindir = os.path.basename(sys.argv[0])
self.searchpath = (bindir, ) if bindir else os.environ['PATH'].split(':')

Expand All @@ -783,8 +779,8 @@ def parsename(self, namestr: str) -> Optional[Flavorname]:
is_old = True
if not is_old:
raise
if not self.quiet and flavorname is not None and self.prefer_old != is_old:
print(f"WARNING: flavor name not v{2 - self.prefer_old}: {namestr}")
if not self.quiet and flavorname is not None and is_old:
print(f"WARNING: flavor name not v2: {namestr}")
return flavorname

def outname(self, flavorname):
Expand All @@ -796,33 +792,6 @@ def old_to_new(self, nm):
def new_to_old(self, nm):
return SyntaxV1.from_v2(nm)

def findflvfile(self, fnm):
"""Search for flavor file and return found path"""
if os.path.isfile(fnm):
return fnm
raise RuntimeError(f"Flavor yaml file not found: {fnm}")

def readflavors(self, fnm, v3mode):
"""Read mandatory and recommended flavors from passed YAML file"""
fnm = self.findflvfile(fnm)
if self.debug:
print(f"DEBUG: Reading flavors from {fnm}")
with open(fnm, "r", encoding="UTF-8)") as fobj:
yamldict = yaml.safe_load(fobj)
# Translate to old names in-place
if self.prefer_old:
for name_type in yamldict["SCS-Spec"].values():
for i, name in enumerate(name_type):
name_type[i] = self.new_to_old(name)
mand = yamldict["SCS-Spec"]["MandatoryFlavors"]
recd = yamldict["SCS-Spec"]["RecommendedFlavors"]
if v3mode:
mand.extend(yamldict["SCS-Spec"].get("MandatoryFlavorsV3", ()))
recd.extend(yamldict["SCS-Spec"].get("RecommendedFlavorsV3", ()))
return mand, recd
else:
return [*mand, *recd], []


if __name__ == "__main__":
namestr = "SCS-16T-64-3x10s_bms_hwv_i3h_GNa-64_ib"
Expand Down
132 changes: 1 addition & 131 deletions Tests/scs-compatible-iaas.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
# -- informal edit log --
# whenever old content is removed as per scs-0003-v1, add a line of the form
# - YYYY-MM-DD pruned old content; affected versions: vN, ...
# - 2025-05-22 pruned old content; affected versions: v1, v2, v3-orig, v5
name: SCS-compatible IaaS
uuid: 50393e6f-2ae1-4c5c-a62c-3b75f2abef3f
url: https://raw.githubusercontent.com/SovereignCloudStack/standards/main/Tests/scs-compatible-iaas.yaml
variables:
- os_cloud
modules:
- id: opc-v2020.11
name: OpenStack Powered Compute v2020.11
url: https://opendev.org/openinfra/interop/src/branch/master/guidelines/2020.11.json
- id: opc-v2022.11
name: OpenStack Powered Compute v2022.11
url: https://opendev.org/openinfra/interop/src/branch/master/guidelines/2022.11.json
- id: scs-0100-v1
name: Flavor naming v1
url: https://docs.scs.community/standards/scs-0100-v1-flavor-naming
run:
- executable: ./iaas/flavor-naming/flavor-names-openstack.py
args: -c {os_cloud} --v1prefer
testcases:
- id: flavor-name-check
tags: [mandatory]
description: >
Must fulfill all requirements of
<https://docs.scs.community/standards/scs-0100-v1-flavor-naming>
- id: scs-0100-v2
name: Flavor naming v2
url: https://docs.scs.community/standards/scs-0100-v2-flavor-naming
run:
- executable: ./iaas/flavor-naming/flavor-names-openstack.py
args: -c {os_cloud}
testcases:
- id: flavor-name-check
tags: [mandatory]
description: >
Must fulfill all requirements of
<https://docs.scs.community/standards/scs-0100-v2-flavor-naming>
- id: scs-0100-v3.0
name: Flavor naming v3.0
url: https://docs.scs.community/standards/scs-0100-v3-flavor-naming
run:
- executable: ./iaas/flavor-naming/flavor-names-openstack.py
args: --v3 -c {os_cloud}
# Note: "--v3 --v2plus" would outlaw the v1 flavor names. Don't do this yet.
testcases:
- id: flavor-name-check
tags: [mandatory]
description: >
Must fulfill all requirements of
<https://docs.scs.community/standards/scs-0100-v3-flavor-naming> -- plus the list of mandatory
and recommended flavors found in <https://docs.scs.community/standards/scs-0100-v2-flavor-naming#standard-scs-flavors>
- id: scs-0100-v3.1
name: Flavor naming v3.1
url: https://docs.scs.community/standards/scs-0100-v3-flavor-naming
Expand Down Expand Up @@ -246,52 +206,6 @@ timeline:
v5.1: effective
v4: effective
v3: deprecated
- date: 2024-11-21
versions:
v5: effective
v4: effective
v3: deprecated
- date: 2024-11-08
versions:
v5: draft
v4: effective
v3: deprecated
- date: 2024-08-23
versions:
v5: draft
v4: effective
v3: deprecated
v3-orig: deprecated
- date: 2024-07-31
versions:
v4: effective
- date: 2024-04-30
versions:
v4: effective
v3: warn
- date: 2024-02-28
versions:
v4: effective
v3: effective
- date: 2023-11-30
versions:
v3: effective
- date: 2023-10-31
versions:
v3: effective
v2: effective
- date: 2023-06-15
versions:
v3: effective
v2: effective
v1: effective
- date: 2023-03-23
versions:
v1: effective
v2: effective
- date: 2021-01-01
versions:
v1: effective
versions:
- version: v5.1 # copy of v5, but with include "scs-0123-v1", which had simply been forgotten
stabilized_at: 2024-12-19
Expand All @@ -314,26 +228,6 @@ versions:
targets:
main: mandatory
preview: domain-manager/availability-zones/service-apis-docs
- version: v5
stabilized_at: 2024-11-14
include:
- opc-v2022.11
- scs-0100-v3.1
- scs-0101-v1
- scs-0102-v1
- scs-0103-v1
- ref: scs-0104-v1
parameters:
image_spec: https://raw.githubusercontent.com/SovereignCloudStack/standards/main/Tests/iaas/scs-0104-v1-images-v5.yaml
- scs-0114-v1
- scs-0115-v1
- scs-0116-v1
- scs-0117-v1
- scs-0121-v1
- scs-0302-v1
targets:
main: mandatory
preview: domain-manager/availability-zones/service-apis-docs
- version: v4
stabilized_at: 2024-02-28
include:
Expand All @@ -358,27 +252,3 @@ versions:
- scs-0102-v1
targets:
main: mandatory
- version: v3-orig
stabilized_at: 2023-06-15
include:
- opc-v2022.11
- scs-0100-v3.0
- scs-0102-v1
targets:
main: mandatory
- version: v2
stabilized_at: 2023-03-23
include:
- opc-v2022.11
- scs-0100-v2
- scs-0102-v1
targets:
main: mandatory
- version: v1
stabilized_at: 2021-01-01
include:
- opc-v2020.11
- scs-0100-v1
- scs-0102-v1
targets:
main: mandatory