summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Tomasiak <jacek.tomasiak@gmail.com>2018-03-15 11:59:07 +0100
committerJacek Tomasiak <jacek.tomasiak@gmail.com>2018-03-27 15:39:18 +0200
commitca4fb9b1cfe2693771e6b0d346d5923db66696e8 (patch)
tree9c9194e85b9cde049e800c09fe0d6721bb3a5872
parent93012b2df1b06843df94d73a704db649d41e8591 (diff)
downloadironic-ca4fb9b1cfe2693771e6b0d346d5923db66696e8.tar.gz
Allow Swift endpoint override
Swiftclient uses public endpoint by default. Ironic uses the base URL from Swift connection to build TempURLs for generated images. Some drivers (e.g. iLO) use those TempURLs to mount images as vmedia. With public URLs it will fail if the BMC doesn't have access to the public network. This change introduces an option to explicitly set the endpoint URL used for Swift. This is a stable-only change as the problem is fixed by refactoring changes in later releases. This is the only version where Ironic uses public Swift endpoints and there is no option to override this. Change-Id: I639a421fa06fff7ab07b8eab557531b8f36c5ed9 Closes-Bug: #1755164 Related-Bug: #1699547
-rw-r--r--ironic/common/swift.py5
-rw-r--r--ironic/conf/swift.py3
-rw-r--r--ironic/tests/unit/common/test_swift.py11
-rw-r--r--releasenotes/notes/swift-endpoint-override-4151d2fbb159950d.yaml8
4 files changed, 27 insertions, 0 deletions
diff --git a/ironic/common/swift.py b/ironic/common/swift.py
index 8168870ee..4f1488ca5 100644
--- a/ironic/common/swift.py
+++ b/ironic/common/swift.py
@@ -55,6 +55,11 @@ class SwiftAPI(object):
# with swift is initialized. Since v3.2.0 swiftclient supports
# instantiating the API client from keystoneauth session.
params = {'session': _get_swift_session()}
+
+ if CONF.swift.endpoint_override:
+ params['os_options'] = {
+ 'object_storage_url': CONF.swift.endpoint_override}
+
self.connection = swift_client.Connection(**params)
def create_object(self, container, obj, filename,
diff --git a/ironic/conf/swift.py b/ironic/conf/swift.py
index 66a0b1f5c..6e1a287b0 100644
--- a/ironic/conf/swift.py
+++ b/ironic/conf/swift.py
@@ -20,6 +20,9 @@ from ironic.common.i18n import _
from ironic.conf import auth
opts = [
+ cfg.StrOpt('endpoint_override',
+ help=_('Always use this endpoint URL for requests to Swift. '
+ 'It also controls base URL used for image TempURLs.')),
cfg.IntOpt('swift_max_retries',
default=2,
help=_('Maximum number of times to retry a Swift request, '
diff --git a/ironic/tests/unit/common/test_swift.py b/ironic/tests/unit/common/test_swift.py
index f9b07e4ba..f5d3dd364 100644
--- a/ironic/tests/unit/common/test_swift.py
+++ b/ironic/tests/unit/common/test_swift.py
@@ -47,6 +47,17 @@ class SwiftTestCase(base.TestCase):
connection_mock.assert_called_once_with(
session=keystone_mock.return_value)
+ def test___init___endpoint(self, connection_mock, keystone_mock):
+ """Check if client is properly initialized with endpoint override"""
+
+ CONF.swift.endpoint_override = 'dummy_override_url'
+
+ swift.SwiftAPI()
+ connection_mock.assert_called_once_with(
+ session=keystone_mock.return_value,
+ os_options={'object_storage_url': 'dummy_override_url'}
+ )
+
def test___init___radosgw(self, connection_mock, swift_session_mock):
"""Check if client is properly initialized with radosgw"""
diff --git a/releasenotes/notes/swift-endpoint-override-4151d2fbb159950d.yaml b/releasenotes/notes/swift-endpoint-override-4151d2fbb159950d.yaml
new file mode 100644
index 000000000..79013e424
--- /dev/null
+++ b/releasenotes/notes/swift-endpoint-override-4151d2fbb159950d.yaml
@@ -0,0 +1,8 @@
+---
+fixes:
+ - Adds ``[swift]/endpoint_override`` option to explicitly set the endpoint
+ URL used for Swift. Ironic uses the Swift connection URL as a base for
+ generation of some TempURLs. Added parameter enables operators to fix
+ the problem when image is attached (via TempURL) as vmedia (e.g. in iLO
+ driver) and BMC doesn't have connectivity to public network.
+ By default this parameter is not set for backward compatibility.