Skip to content

Commit

Permalink
fixed some attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Sep 23, 2024
1 parent f80e060 commit c96f360
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 20 additions & 1 deletion simple_vm_client/openstack_connector/openstack_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
3 changes: 1 addition & 2 deletions simple_vm_client/util/thrift_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c96f360

Please sign in to comment.