Merge "Make Swift endpoint type configurable"
This commit is contained in:
commit
cf58f63ab4
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue