1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
This commit is contained in:
Chris Church 2015-08-10 15:35:30 -04:00
parent 3e5dbd045f
commit da56312322

View file

@ -51,11 +51,12 @@ import shade
class OpenStackInventory(object): class OpenStackInventory(object):
def __init__(self, private=False, refresh=False): def __init__(self, private=False, refresh=False):
config_files = os_client_config.config.CONFIG_FILES
config_files.append('/etc/ansible/openstack.yml')
self.openstack_config = os_client_config.config.OpenStackConfig( self.openstack_config = os_client_config.config.OpenStackConfig(
os_client_config.config.CONFIG_FILES.append( config_files)
'/etc/ansible/openstack.yml'),
private)
self.clouds = shade.openstack_clouds(self.openstack_config) self.clouds = shade.openstack_clouds(self.openstack_config)
self.private = private
self.refresh = refresh self.refresh = refresh
self.cache_max_age = self.openstack_config.get_cache_max_age() self.cache_max_age = self.openstack_config.get_cache_max_age()
@ -92,6 +93,7 @@ class OpenStackInventory(object):
hostvars = collections.defaultdict(dict) hostvars = collections.defaultdict(dict)
for cloud in self.clouds: for cloud in self.clouds:
cloud.private = cloud.private or self.private
# Cycle on servers # Cycle on servers
for server in cloud.list_servers(): for server in cloud.list_servers():
@ -152,7 +154,7 @@ def main():
elif args.host: elif args.host:
inventory.get_host(args.host) inventory.get_host(args.host)
except shade.OpenStackCloudException as e: except shade.OpenStackCloudException as e:
print(e.message) sys.stderr.write('%s\n' % e.message)
sys.exit(1) sys.exit(1)
sys.exit(0) sys.exit(0)