From 853c2520042243053c98aec8058e5d43ceb023fe Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 28 Jan 2019 10:45:29 +0000 Subject: [PATCH] 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 --- bifrost/inventory.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index baf2d862f..5a021a59d 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -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"