summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMonty Taylor <mordred@redhat.com>2018-06-18 15:41:15 -0500
committerGitHub <noreply@github.com>2018-06-18 15:41:15 -0500
commit16fb74ffb3b202bc0f308c2bf4a9312e6a31177a (patch)
tree73e1da51658fa1b311c39bb90a0328ac2807f783 /contrib
parenta79b6ec8a2128dbe5ed4f14e7867d91cb3fce4b6 (diff)
downloadansible-16fb74ffb3b202bc0f308c2bf4a9312e6a31177a.tar.gz
Fix openstack inventory script for multi-cloud case (#41664)
The shift to openstacksdk left us with a bug in that when running bare with --list, the cloud argument to get_one is None. We just need _one_ of the clouds to pull the cache settings, since they are global (yet, we'll go back and fix this in sdk) If it's None, just use get_all and grab the first one.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/inventory/openstack_inventory.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/inventory/openstack_inventory.py b/contrib/inventory/openstack_inventory.py
index cf7bed949d..1bb5e17de9 100755
--- a/contrib/inventory/openstack_inventory.py
+++ b/contrib/inventory/openstack_inventory.py
@@ -192,8 +192,12 @@ def is_cache_stale(cache_file, cache_expiration_time, refresh=False):
def get_cache_settings(cloud=None):
config_files = cloud_config.CONFIG_FILES + CONFIG_FILES
- config = cloud_config.OpenStackConfig(
- config_files=config_files).get_one(cloud=cloud)
+ if cloud:
+ config = cloud_config.OpenStackConfig(
+ config_files=config_files).get_one(cloud=cloud)
+ else:
+ config = cloud_config.OpenStackConfig(
+ config_files=config_files).get_all()[0]
# For inventory-wide caching
cache_expiration_time = config.get_cache_expiration_time()
cache_path = config.get_cache_path()