From 47e4256eec921b718ebd06fc5c0aab891250ecaa Mon Sep 17 00:00:00 2001 From: dweinholz Date: Mon, 7 Nov 2022 16:30:28 +0100 Subject: [PATCH] fix(Cluster):if image deleted try to parse name --- VirtualMachineService/VirtualMachineHandler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 81e42f6e..55d9bebe 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -2061,10 +2061,14 @@ def add_cluster_machine( project_name, project_id, ): - LOG.info(f"Add machine to [{name}] {cluster_id} - {key_name}") - openstack_image = self.get_image(image=image) - if not openstack_image: + LOG.info(f"Add machine to [{name}] {cluster_id} - [Image: {image}] - {key_name}") + try: + openstack_image = self.get_image(image=image) + except imageNotFoundException: + openstack_image = None for version in ["18.04", "20.04", "22.04"]: + LOG.info(f"Checking if {version} in {image}") + if version in image: openstack_image = self.get_active_image_by_os_version( os_version=version.replace(".", ""), os_distro="ubuntu" @@ -2072,6 +2076,7 @@ def add_cluster_machine( break if not openstack_image: raise imageNotFoundException(Reason=(f"No Image {image} found!")) + if openstack_image and openstack_image.status != "active": LOG.info(openstack_image) image_os_version = openstack_image.get("os_version", "ubuntu")