From cf117dcc2ba19a146d4eb46530f3ffc8c023f44a Mon Sep 17 00:00:00 2001 From: Yuiko Takada Date: Wed, 12 Aug 2015 18:46:26 +0900 Subject: [PATCH] Make Swift endpoint type configurable Currently, Ironic Inspector talks with Swift using public API endpoint. This patch fix this by making endpoint type configurable and also make default value "internalURL". Change-Id: Iab7d6a995d484bebb4338ffd307afcea132c0f20 Closes-Bug: #1470565 --- example.conf | 6 ++++++ ironic_inspector/common/swift.py | 14 ++++++++++++-- ironic_inspector/test/test_swift.py | 6 +++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/example.conf b/example.conf index 18bdf6f..42999c0 100644 --- a/example.conf +++ b/example.conf @@ -621,3 +621,9 @@ # Keystone authentication URL (string value) #os_auth_url = + +# Swift service type. (string value) +#os_service_type = object-store + +# Swift endpoint type. (string value) +#os_endpoint_type = internalURL diff --git a/ironic_inspector/common/swift.py b/ironic_inspector/common/swift.py index 7259a1d..57e061f 100644 --- a/ironic_inspector/common/swift.py +++ b/ironic_inspector/common/swift.py @@ -55,6 +55,12 @@ SWIFT_OPTS = [ cfg.StrOpt('os_auth_url', default='', help='Keystone authentication URL'), + cfg.StrOpt('os_service_type', + default='object-store', + help='Swift service type.'), + cfg.StrOpt('os_endpoint_type', + default='internalURL', + help='Swift endpoint type.'), ] @@ -74,7 +80,9 @@ class SwiftAPI(object): tenant_name=CONF.swift.tenant_name, key=CONF.swift.password, auth_url=CONF.swift.os_auth_url, - auth_version=CONF.swift.os_auth_version): + auth_version=CONF.swift.os_auth_version, + service_type=CONF.swift.os_service_type, + endpoint_type=CONF.swift.os_endpoint_type): """Constructor for creating a SwiftAPI object. :param user: the name of the user for Swift account @@ -88,7 +96,9 @@ class SwiftAPI(object): 'tenant_name': tenant_name, 'key': key, 'authurl': auth_url, - 'auth_version': auth_version} + 'auth_version': auth_version, + 'os_options': {'service_type': service_type, + 'endpoint_type': endpoint_type}} self.connection = swift_client.Connection(**params) diff --git a/ironic_inspector/test/test_swift.py b/ironic_inspector/test/test_swift.py index e386456..f0f0622 100644 --- a/ironic_inspector/test/test_swift.py +++ b/ironic_inspector/test/test_swift.py @@ -45,6 +45,8 @@ class SwiftTestCase(base.BaseTest): CONF.set_override('os_auth_url', 'http://authurl/v2.0', 'swift') CONF.set_override('os_auth_version', '2', 'swift') CONF.set_override('max_retries', 2, 'swift') + CONF.set_override('os_service_type', 'object-store', 'swift') + CONF.set_override('os_endpoint_type', 'internalURL', 'swift') # The constructor of SwiftAPI accepts arguments whose # default values are values of some config options above. So reload @@ -58,7 +60,9 @@ class SwiftTestCase(base.BaseTest): 'tenant_name': 'tenant', 'key': 'password', 'authurl': 'http://authurl/v2.0', - 'auth_version': '2'} + 'auth_version': '2', + 'os_options': {'service_type': 'object-store', + 'endpoint_type': 'internalURL'}} connection_mock.assert_called_once_with(**params) def test_create_object(self, connection_mock):