mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix broken cache logic
This commit is contained in:
parent
3861597696
commit
b7d644d484
1 changed files with 12 additions and 2 deletions
|
@ -226,6 +226,9 @@ or environment variables (DO_API_TOKEN)'''
|
||||||
self.build_inventory()
|
self.build_inventory()
|
||||||
json_data = self.inventory
|
json_data = self.inventory
|
||||||
|
|
||||||
|
if self.cache_refreshed:
|
||||||
|
self.write_to_cache()
|
||||||
|
|
||||||
if self.args.pretty:
|
if self.args.pretty:
|
||||||
print json.dumps(json_data, sort_keys=True, indent=2)
|
print json.dumps(json_data, sort_keys=True, indent=2)
|
||||||
else:
|
else:
|
||||||
|
@ -309,23 +312,30 @@ or environment variables (DO_API_TOKEN)'''
|
||||||
'''Get JSON from DigitalOcean API'''
|
'''Get JSON from DigitalOcean API'''
|
||||||
if self.args.force_cache:
|
if self.args.force_cache:
|
||||||
return
|
return
|
||||||
|
# We always get fresh droplets
|
||||||
|
if self.is_cache_valid() and not (resource=='droplets' or resource is None):
|
||||||
|
return
|
||||||
if self.args.refresh_cache:
|
if self.args.refresh_cache:
|
||||||
resource=None
|
resource=None
|
||||||
|
|
||||||
if resource == 'droplets' or resource is None:
|
if resource == 'droplets' or resource is None:
|
||||||
self.data['droplets'] = self.manager.all_active_droplets()
|
self.data['droplets'] = self.manager.all_active_droplets()
|
||||||
|
self.cache_refreshed = True
|
||||||
if resource == 'regions' or resource is None:
|
if resource == 'regions' or resource is None:
|
||||||
self.data['regions'] = self.manager.all_regions()
|
self.data['regions'] = self.manager.all_regions()
|
||||||
|
self.cache_refreshed = True
|
||||||
if resource == 'images' or resource is None:
|
if resource == 'images' or resource is None:
|
||||||
self.data['images'] = self.manager.all_images(filter=None)
|
self.data['images'] = self.manager.all_images(filter=None)
|
||||||
|
self.cache_refreshed = True
|
||||||
if resource == 'sizes' or resource is None:
|
if resource == 'sizes' or resource is None:
|
||||||
self.data['sizes'] = self.manager.sizes()
|
self.data['sizes'] = self.manager.sizes()
|
||||||
|
self.cache_refreshed = True
|
||||||
if resource == 'ssh_keys' or resource is None:
|
if resource == 'ssh_keys' or resource is None:
|
||||||
self.data['ssh_keys'] = self.manager.all_ssh_keys()
|
self.data['ssh_keys'] = self.manager.all_ssh_keys()
|
||||||
|
self.cache_refreshed = True
|
||||||
if resource == 'domains' or resource is None:
|
if resource == 'domains' or resource is None:
|
||||||
self.data['domains'] = self.manager.all_domains()
|
self.data['domains'] = self.manager.all_domains()
|
||||||
|
self.cache_refreshed = True
|
||||||
self.write_to_cache()
|
|
||||||
|
|
||||||
|
|
||||||
def build_inventory(self):
|
def build_inventory(self):
|
||||||
|
|
Loading…
Reference in a new issue