Skip to content

Commit

Permalink
fix when timezone is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
mnecas committed Apr 28, 2020
1 parent 08bf6c6 commit 1daa0bb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/inventory/ovirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

import sys

from datetime import timezone
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible.errors import AnsibleError, AnsibleParserError

Expand Down Expand Up @@ -128,7 +129,7 @@ def _get_dict_of_struct(self, vm):
'os_type': vm.os.type,
'template': self.connection.follow_link(vm.template).name,
'creation_time': str(vm.creation_time),
'creation_time_timestamp': vm.creation_time.timestamp(),
'creation_time_timestamp': vm.creation_tim.timestamp() if vm.creation_tim.tzinfo else vm.creation_tim.replace(tzinfo=timezone.utc).timestamp(),
'tags': [tag.name for tag in tags],
'affinity_labels': [label.name for label in labels],
'affinity_groups': [
Expand Down

0 comments on commit 1daa0bb

Please sign in to comment.