1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add a config option for rackspace inventory cache

Adding a config and environment variable option for tuning the cache age
check in the rackspace inventory module
This commit is contained in:
Matthew Jones 2016-01-20 15:03:56 -05:00
parent e3a6accc1d
commit a106382786

View file

@ -355,9 +355,12 @@ def get_cache_file_path(regions):
def _list(regions, refresh_cache=True): def _list(regions, refresh_cache=True):
cache_max_age = int(get_config(p, 'rax', 'cache_max_age',
'RAX_CACHE_MAX_AGE', 600))
if (not os.path.exists(get_cache_file_path(regions)) or if (not os.path.exists(get_cache_file_path(regions)) or
refresh_cache or refresh_cache or
(time() - os.stat(get_cache_file_path(regions))[-1]) > 600): (time() - os.stat(get_cache_file_path(regions))[-1]) > cache_max_age):
# Cache file doesn't exist or older than 10m or refresh cache requested # Cache file doesn't exist or older than 10m or refresh cache requested
_list_into_cache(regions) _list_into_cache(regions)