From 2397fd6d87fce2fbc232abfdf18fbcadab46fdda Mon Sep 17 00:00:00 2001 From: Brent Tang Date: Tue, 21 Mar 2017 21:06:13 -0700 Subject: [PATCH] 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 --- nova_powervm/conf/powervm.py | 5 ++++- nova_powervm/tests/virt/powervm/nvram/test_swift.py | 4 ++++ nova_powervm/virt/powervm/nvram/swift.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nova_powervm/conf/powervm.py b/nova_powervm/conf/powervm.py index aa5d204a..ab48757b 100644 --- a/nova_powervm/conf/powervm.py +++ b/nova_powervm/conf/powervm.py @@ -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 = [ diff --git a/nova_powervm/tests/virt/powervm/nvram/test_swift.py b/nova_powervm/tests/virt/powervm/nvram/test_swift.py index c8cc69b2..c6546811 100644 --- a/nova_powervm/tests/virt/powervm/nvram/test_swift.py +++ b/nova_powervm/tests/virt/powervm/nvram/test_swift.py @@ -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']) diff --git a/nova_powervm/virt/powervm/nvram/swift.py b/nova_powervm/virt/powervm/nvram/swift.py index 1a2dc045..94b1102a 100644 --- a/nova_powervm/virt/powervm/nvram/swift.py +++ b/nova_powervm/virt/powervm/nvram/swift.py @@ -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