Config Option for Endpoint Type for Swift

The Swift client will use the Keystone Service Catalog to lookup the
URL to use when connecting to the various Swift Services.  By default
it will use the 'publicURL' endpoint/interface type for which URL to
use.  However, depending on the configuration of the environment, it
may be desired to use another endpoint/interface type, such as
"internalURL".

This change will add a configuration option, similar to the others
provided in nova-powervm for Swift client options, to be able to
specify this endpoint/interface type in a 'swift_endpoint_type'
property that will map to the os_endpoint_type option for Swift.

Change-Id: Id6421cc167ef92d31a7ebcb2a8ffb43e6bc72412
This commit is contained in:
Brent Tang 2017-03-21 21:06:13 -07:00
parent 59d3164bd8
commit 2397fd6d87
3 changed files with 9 additions and 1 deletions

View File

@ -204,7 +204,10 @@ swift_opts = [
cfg.StrOpt('swift_auth_url', help='The Keystone authorization url. '
'Example: "http://keystone-hostname:5000/v3"'),
cfg.StrOpt('swift_cacert', required=False, help='Path to CA certificate '
'file. Example: /etc/swiftclient/myca.pem')
'file. Example: /etc/swiftclient/myca.pem'),
cfg.StrOpt('swift_endpoint_type', help='The endpoint/interface type for '
'the Swift client to select from the Keystone Service Catalog '
'for the connection URL. Swift defaults to "publicURL".')
]
vnc_opts = [

View File

@ -313,7 +313,11 @@ class TestSwiftStore(test.TestCase):
"""Test optional config values."""
# Not in the sparse one from setUp()
self.assertIsNone(self.swift_store.options['os_cacert'])
self.assertIsNone(self.swift_store.options['os_endpoint_type'])
# Create a new one with the optional values set
self.flags(swift_cacert='/path/to/ca.pem', group='powervm')
self.flags(swift_endpoint_type='internalURL', group='powervm')
swift_store = swift.SwiftNvramStore()
self.assertEqual('/path/to/ca.pem', swift_store.options['os_cacert'])
self.assertEqual('internalURL',
swift_store.options['os_endpoint_type'])

View File

@ -65,6 +65,7 @@ class SwiftNvramStore(api.NvramStore):
'os_project_domain_name': CONF.powervm.swift_project_domain_name,
'os_auth_url': CONF.powervm.swift_auth_url,
'os_cacert': CONF.powervm.swift_cacert,
'os_endpoint_type': CONF.powervm.swift_endpoint_type,
}
return options