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
This commit is contained in:
Yuiko Takada 2015-08-12 18:46:26 +09:00
parent fd7d609ef1
commit cf117dcc2b
3 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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):