diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index a6ca838d..3978cabc 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -1991,14 +1991,10 @@ 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 @@ -2006,6 +2002,7 @@ def get_active_image_by_os_version(self, os_version, os_distro): if os_distro and os_distro == image_os_distro: return image elif os_distro is None: + return image return None @@ -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 )