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

Commit

Permalink
fix(BaseIMage):read from properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jul 5, 2022
1 parent a17ba93 commit b6f6302
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1991,21 +1991,18 @@ def get_active_image_by_os_version(self, os_version, os_distro):
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", None)
properties = image.get("properties", None)
base_image_ref = None
if 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 properties:
base_image_ref = properties.get("base_image_ref", 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

Expand Down Expand Up @@ -2038,16 +2035,8 @@ def add_cluster_machine(
raise imageNotFoundException(Reason=(f"No Image {image} found!"))
if image and image.status != "active":
LOG.info(image)
image_os_version = image.get("os_version", None)
image_os_distro = image.get("os_distro", None)
if not image_os_distro or not image_os_version:
metadata = image.get("metadata", None)
if metadata:
image_os_version = metadata.get("os_version", "ubuntu")
image_os_distro = metadata.get("os_distro", "1804")
else:
image_os_version = "ubuntu"
image_os_distro = "1804"
image_os_version = image.get("os_version", "ubuntu")
image_os_distro = image.get("os_distro", "1804")
image = self.get_active_image_by_os_version(
os_version=image_os_version, os_distro=image_os_distro
)
Expand Down

0 comments on commit b6f6302

Please sign in to comment.