Allow Ironic URL to use env vars in bifrost_inventory.py

Currently the URL used in bifrost_inventory.py is hard-coded to
http://localhost:6385, which might not be valid if we are accessing a remote
API or the service is bound to a specific IP.

The URL can be specified using either OS_URL or IRONIC_URL, with the former
taking precedence.

This patch also adds support for using clouds.yaml with bifrost_inventory.py.

Change-Id: I8741feb05a0a1cdd55f2e1f8d4cea8fcfefed192
This commit is contained in:
Mark Goddard 2019-01-28 10:45:29 +00:00
parent a0b4577b7d
commit 853c252004
1 changed files with 5 additions and 1 deletions

View File

@ -325,9 +325,13 @@ def _process_baremetal_csv(data_source, groups, hostvars):
def _identify_shade_auth():
"""Return shade credentials"""
if os.environ.get('OS_CLOUD'):
return {}
endpoint = os.getenv('OS_URL',
os.getenv('IRONIC_URL', "http://localhost:6385/"))
options = dict(
auth_type="None",
auth=dict(endpoint="http://localhost:6385/",)
auth=dict(endpoint=endpoint,)
)
if os.environ.get('OS_AUTH_URL'):
options['auth_type'] = "password"