Skip to content

Commit 3b88759

Browse files
committed
Servers deleted with end_time=None must have an end time
If a server is deleted, but remains without end_date (for example because the server did never start) we still have to return and end_date, otherwise the server will never be completed. Fixes #71
1 parent 2158309 commit 3b88759

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

caso/extract/nova.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ def _get_server_start(server):
113113
@staticmethod
114114
def _get_server_end(server):
115115
server_end = server.__getattr__('OS-SRV-USG:terminated_at')
116+
if server_end is None:
117+
# If the server has no end_time, and no launched_at, we should use
118+
# server.created as the end time (i.e. VM has not started at all)
119+
if server.__getattr__("OS-SRV-USG:launched_at") is None:
120+
server_end = server.created
121+
# Then, if a server is deleted, stuck in task_status deleting, and
122+
# the end time is None, we have to return the updated time as the
123+
# end date, otherwise these server will never be completed.
124+
elif server.status == "DELETED":
125+
server_end = server.updated
116126
if server_end:
117127
server_end = dateutil.parser.parse(server_end)
118128
server_end = server_end.replace(tzinfo=None)

0 commit comments

Comments
 (0)