Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
fixed also for other image function
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jul 5, 2022
1 parent 0a2a52a commit 380fa8b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,19 +1989,23 @@ def get_active_image_by_os_version(self, os_version, os_distro):
LOG.info(f"Get active Image by os-version: {os_version}")
images = self.conn.list_images()
for image in images:
metadata = image["metadata"]
image_os_version = metadata.get("os_version", None)
image_os_distro = metadata.get("os_distro", None)
base_image_ref = metadata.get("base_image_ref", None)
if (
os_version == image_os_version
and image.status == "active"
and base_image_ref is None
):
if os_distro and os_distro == image_os_distro:
return image
elif os_distro is None:
return image
if image and image.status == "active":
image_os_version = image.get("os_version", None)
image_os_distro = image.get("os_distro", None)
metadata = image.get("metadata", {})
base_image_ref = metadata.get("base_image_ref", None)

if not image_os_distro or not image_os_version:
image_os_version = metadata.get("os_version", None)
image_os_distro = metadata.get("os_distro", None)
if (
os_version == image_os_version
and base_image_ref is None
):
if os_distro and os_distro == image_os_distro:
return image
elif os_distro is None:
return image
return None

def create_deactivate_update_script(self):
Expand Down

0 comments on commit 380fa8b

Please sign in to comment.