From a1063827867cada5414577a85e2f13121cb7b948 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 20 Jan 2016 15:03:56 -0500 Subject: [PATCH 1/2] 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 --- contrib/inventory/rax.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/inventory/rax.py b/contrib/inventory/rax.py index 0028f54d20..4ac6b0f47e 100755 --- a/contrib/inventory/rax.py +++ b/contrib/inventory/rax.py @@ -355,9 +355,12 @@ def get_cache_file_path(regions): 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 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 _list_into_cache(regions) From a1318e16641a89cfbd41d072670d374bbd0b3cf7 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 20 Jan 2016 15:27:06 -0500 Subject: [PATCH 2/2] Add rax cache age ini documentation --- contrib/inventory/rax.ini | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/inventory/rax.ini b/contrib/inventory/rax.ini index 5a269e16a3..15948e7b2e 100644 --- a/contrib/inventory/rax.ini +++ b/contrib/inventory/rax.ini @@ -55,3 +55,12 @@ # will be ignored, and 4 will be used. Accepts a comma separated list, # the first found wins. # access_ip_version = 4 + +# Environment Variable: RAX_CACHE_MAX_AGE +# Default: 600 +# +# A configuration the changes the behavior or the inventory cache. +# Inventory listing performed before this value will be returned from +# the cache instead of making a full request for all inventory. Setting +# this value to 0 will force a full request. +# cache_max_age = 600 \ No newline at end of file