Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only consider image properties of public/community images. #724

Merged
merged 5 commits into from
Sep 2, 2024
Merged
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
24 changes: 20 additions & 4 deletions Tests/iaas/entropy/entropy-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def print_usage(file=sys.stderr):
[-c/--os-cloud OS_CLOUD] sets cloud environment (default from OS_CLOUD env)
[-d/--debug] enables DEBUG logging channel
[-i/--images IMAGE_LIST] sets images to be tested, separated by comma.
[-V/--image-visibility VIS_LIST] filters images by visibility
(default: 'public,community'; use '*' to disable)
""", end='', file=file)


Expand Down Expand Up @@ -343,9 +345,7 @@ def _deduce_sort_ubuntu(os_version, ubuntu_ver=re.compile(r"\d\d\.\d\d\Z")):


def _deduce_sort(img):
# avoid private images here
# (note that with SCS, public images MUST have os_distro and os_version, but we check nonetheless)
if img.visibility != 'public' or not img.os_distro or not img.os_version:
if not img.os_distro or not img.os_version:
return 0, 0
deducer = DISTROS.get(img.os_distro.strip().lower())
if deducer is None:
Expand Down Expand Up @@ -401,14 +401,15 @@ def main(argv):
logger.addHandler(counting_handler)

try:
opts, args = getopt.gnu_getopt(argv, "c:i:hd", ["os-cloud=", "images=", "help", "debug"])
opts, args = getopt.gnu_getopt(argv, "c:i:hdV:", ["os-cloud=", "images=", "help", "debug", "image-visibility="])
except getopt.GetoptError as exc:
logger.critical(f"{exc}")
print_usage()
return 1

cloud = os.environ.get("OS_CLOUD")
image_names = set()
image_visibility = set()
for opt in opts:
if opt[0] == "-h" or opt[0] == "--help":
print_usage()
Expand All @@ -419,17 +420,32 @@ def main(argv):
cloud = opt[1]
if opt[0] == "-d" or opt[0] == "--debug":
logging.getLogger().setLevel(logging.DEBUG)
if opt[0] == "-V" or opt[0] == "--image-visibility":
image_visibility.update([v.strip() for v in opt[1].split(',')])

if not cloud:
logger.critical("You need to have OS_CLOUD set or pass --os-cloud=CLOUD.")
return 1

if not image_visibility:
image_visibility.update(("public", "community"))

try:
logger.debug(f"Connecting to cloud '{cloud}'")
with openstack.connect(cloud=cloud, timeout=32) as conn:
all_images = conn.list_images()
all_flavors = conn.list_flavors(get_extra=True)

if '*' not in image_visibility:
logger.debug(f"Images: filter for visibility {', '.join(image_visibility)}")
all_images = [img for img in all_images if img.visibility in image_visibility]
all_image_names = [f"{img.name} ({img.visibility})" for img in all_images]
logger.debug(f"Images: {', '.join(all_image_names) or '(NONE)'}")

if not all_images:
logger.critical("Can't run this test without image")
return 1

if image_names:
# find images by the names given, BAIL out if some image is missing
images = sorted([img for img in all_images if img.name in image_names], key=lambda img: img.name)
Expand Down