From c96f360e373465d694dea34a3a607b3b46d959a1 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Mon, 23 Sep 2024 11:42:05 +0200 Subject: [PATCH] fixed some attributes --- .../openstack_connector.py | 21 ++++++++++++++++++- simple_vm_client/util/thrift_converter.py | 3 +-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/simple_vm_client/openstack_connector/openstack_connector.py b/simple_vm_client/openstack_connector/openstack_connector.py index fe8c43d..bcf0fbb 100644 --- a/simple_vm_client/openstack_connector/openstack_connector.py +++ b/simple_vm_client/openstack_connector/openstack_connector.py @@ -345,7 +345,26 @@ def create_volume_by_volume_snap( def get_servers(self) -> list[Server]: logger.info("Get servers") - servers: list[Server] = self.openstack_connection.list_servers(detailed=True) + servers: list[Server] = self.openstack_connection.list_servers() + flavors = {} + images = {} + for server in servers: + flavor = server.flavor + if not flavor.get("name"): + if not flavors.get(flavor.id): + openstack_flavor = self.openstack_connection.get_flavor(flavor.id) + flavors[flavor.id] = openstack_flavor + server.flavor = openstack_flavor + else: + server.flavor = flavors.get(flavor.id) + image = server.image + if not image.get("name"): + if not image.get(flavor.id): + openstack_image = self.openstack_connection.get_image(image.id) + images[image.id] = openstack_image + server.image = openstack_image + else: + server.image = images.get(image.id) return servers def get_servers_by_ids(self, ids: list[str]) -> list[Server]: diff --git a/simple_vm_client/util/thrift_converter.py b/simple_vm_client/util/thrift_converter.py index 490ca59..d1f980c 100644 --- a/simple_vm_client/util/thrift_converter.py +++ b/simple_vm_client/util/thrift_converter.py @@ -18,9 +18,8 @@ def os_to_thrift_image(openstack_image: OpenStack_Image) -> Image: if not properties: properties = {} image_type = properties.get("image_type", "image") - image = Image( - name=openstack_image.name or "N/A", + name=openstack_image.name, min_disk=openstack_image.min_disk, min_ram=openstack_image.min_ram, status=openstack_image.status,