diff --git a/example.conf b/example.conf index 18bdf6f4e..42999c025 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 7259a1dcf..57e061f57 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 e3864563e..f0f0622af 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):