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

Commit

Permalink
updated to list_server
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Nov 25, 2019
1 parent 3c34d02 commit cc70ce6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,15 @@ def openstack_server_to_thrift_server(self, server):
self.logger.info("Convert server {} to thrift server".format(server))
fixed_ip = None
floating_ip = None
diskspace = 0

if server["os-extended-volumes:volumes_attached"]:
volume_id = server["os-extended-volumes:volumes_attached"][0]["id"]
diskspace = self.conn.block_storage.get_volume(volume_id).to_dict()["size"]
else:
diskspace = 0
try:
diskspace = self.conn.block_storage.get_volume(volume_id).to_dict()["size"]
except Exception as e:
self.logger.exception("Could not found volume {}: {}".format(volume_id, e))

if server["OS-SRV-USG:launched_at"]:
dt = datetime.datetime.strptime(
server["OS-SRV-USG:launched_at"][:-7], "%Y-%m-%dT%H:%M:%S"
Expand Down

0 comments on commit cc70ce6

Please sign in to comment.