From e6fb7bc3850e0b7503f515cfcc553305674e759d Mon Sep 17 00:00:00 2001 From: "Haomeng, Wang" Date: Wed, 3 Jun 2015 06:34:16 +0000 Subject: [PATCH] Support standalone ironic Add two options in this patch to support standalone ironic without keystone services. *auth_strategy *ironic_url Change-Id: Iffa50a40971264aacc97f7210aa227a6655eaf42 Closes-bug: 1459471 --- example.conf | 9 +++++++++ ironic_inspector/conf.py | 9 +++++++++ ironic_inspector/utils.py | 13 +++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/example.conf b/example.conf index f8c116376..223559962 100644 --- a/example.conf +++ b/example.conf @@ -113,6 +113,15 @@ # Deprecated group/name - [discoverd]/ironic_retry_period #ironic_retry_period = 5 +# Method to use for authentication: noauth or keystone. (string value) +# Allowed values: keystone, noauth +#auth_strategy = keystone + +# Ironic API URL, used to set Ironic API URL when auth_strategy option +# is noauth to work with standalone Ironic without keystone. (string +# value) +#ironic_url = http://localhost:6385/ + [processing] diff --git a/ironic_inspector/conf.py b/ironic_inspector/conf.py index ea1cc652e..5fc77e1b4 100644 --- a/ironic_inspector/conf.py +++ b/ironic_inspector/conf.py @@ -50,6 +50,15 @@ IRONIC_OPTS = [ help='Amount of time between attempts to connect to Ironic ' 'on start up.', deprecated_group='discoverd'), + cfg.StrOpt('auth_strategy', + default='keystone', + choices=('keystone', 'noauth'), + help='Method to use for authentication: noauth or keystone.'), + cfg.StrOpt('ironic_url', + default='http://localhost:6385/', + help='Ironic API URL, used to set Ironic API URL when ' + 'auth_strategy option is noauth to work with standalone ' + 'Ironic without keystone.'), ] diff --git a/ironic_inspector/utils.py b/ironic_inspector/utils.py index c7bf47794..6fb5e4b91 100644 --- a/ironic_inspector/utils.py +++ b/ironic_inspector/utils.py @@ -46,10 +46,15 @@ class Error(Exception): def get_client(): # pragma: no cover """Get Ironic client instance.""" - args = dict({'os_password': CONF.ironic.os_password, - 'os_username': CONF.ironic.os_username, - 'os_auth_url': CONF.ironic.os_auth_url, - 'os_tenant_name': CONF.ironic.os_tenant_name}) + # NOTE: To support standalone ironic without keystone + if CONF.ironic.auth_strategy == 'noauth': + args = dict({'os_auth_token': 'noauth', + 'ironic_url': CONF.ironic.ironic_url}) + else: + args = dict({'os_password': CONF.ironic.os_password, + 'os_username': CONF.ironic.os_username, + 'os_auth_url': CONF.ironic.os_auth_url, + 'os_tenant_name': CONF.ironic.os_tenant_name}) return client.get_client(1, **args)