diff options
author | Vladyslav Drok <vdrok@mirantis.com> | 2015-09-30 12:20:49 +0300 |
---|---|---|
committer | Vladyslav Drok <vdrok@mirantis.com> | 2015-10-15 18:57:44 +0300 |
commit | 7d6eb162377a6c3c4803d9516705f01a8dd195b3 (patch) | |
tree | 119712753b3c8786be0e8eca7ebf368e52d71784 /ironic/tests/unit/common/test_glance_service.py | |
parent | 91d7298e17e23e6f35966e9eee828b58bca0c826 (diff) | |
download | ironic-7d6eb162377a6c3c4803d9516705f01a8dd195b3.tar.gz |
Enable radosgw support in ironic
Ceph has a swift compatible API called radosgw. Although it is
compatible, there are some differences with swift in how temp URLs
are generated. This change adds a new config option called
temp_url_endpoint_type, which allows generation of temp URL depending
on the underlying object storage API.
Implements: blueprint radosgw-temp-url
Change-Id: I79cfe92aa19a2a0520fee2455f094d728c748d5c
Diffstat (limited to 'ironic/tests/unit/common/test_glance_service.py')
-rw-r--r-- | ironic/tests/unit/common/test_glance_service.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ironic/tests/unit/common/test_glance_service.py b/ironic/tests/unit/common/test_glance_service.py index 881b86eaa..04828a310 100644 --- a/ironic/tests/unit/common/test_glance_service.py +++ b/ironic/tests/unit/common/test_glance_service.py @@ -25,6 +25,7 @@ import mock from oslo_config import cfg from oslo_context import context from oslo_serialization import jsonutils +from six.moves.urllib import parse as urlparse import testtools from ironic.common import exception @@ -685,6 +686,65 @@ class TestGlanceSwiftTempURL(base.TestCase): method='GET') @mock.patch('swiftclient.utils.generate_temp_url', autospec=True) + def test_swift_temp_url_radosgw(self, tempurl_mock): + self.config(temp_url_endpoint_type='radosgw', group='glance') + path = ('/v1' + '/glance' + '/757274c4-2856-4bd2-bb20-9a4a231e187b') + tempurl_mock.return_value = ( + path + '?temp_url_sig=hmacsig&temp_url_expires=1400001200') + + self.service._validate_temp_url_config = mock.Mock() + + temp_url = self.service.swift_temp_url(image_info=self.fake_image) + + self.assertEqual( + (urlparse.urljoin(CONF.glance.swift_endpoint_url, 'swift') + + tempurl_mock.return_value), + temp_url) + tempurl_mock.assert_called_with( + path=path, + seconds=CONF.glance.swift_temp_url_duration, + key=CONF.glance.swift_temp_url_key, + method='GET') + + @mock.patch('swiftclient.utils.generate_temp_url', autospec=True) + def test_swift_temp_url_radosgw_endpoint_with_swift(self, tempurl_mock): + self.config(swift_endpoint_url='https://swift.radosgw.com/swift', + group='glance') + self.config(temp_url_endpoint_type='radosgw', group='glance') + path = ('/v1' + '/glance' + '/757274c4-2856-4bd2-bb20-9a4a231e187b') + tempurl_mock.return_value = ( + path + '?temp_url_sig=hmacsig&temp_url_expires=1400001200') + + self.service._validate_temp_url_config = mock.Mock() + + temp_url = self.service.swift_temp_url(image_info=self.fake_image) + + self.assertEqual( + CONF.glance.swift_endpoint_url + tempurl_mock.return_value, + temp_url) + tempurl_mock.assert_called_with( + path=path, + seconds=CONF.glance.swift_temp_url_duration, + key=CONF.glance.swift_temp_url_key, + method='GET') + + @mock.patch('swiftclient.utils.generate_temp_url', autospec=True) + def test_swift_temp_url_radosgw_endpoint_invalid(self, tempurl_mock): + self.config(swift_endpoint_url='https://swift.radosgw.com/eggs/', + group='glance') + self.config(temp_url_endpoint_type='radosgw', group='glance') + self.service._validate_temp_url_config = mock.Mock() + + self.assertRaises(exception.InvalidParameterValue, + self.service.swift_temp_url, + self.fake_image) + self.assertFalse(tempurl_mock.called) + + @mock.patch('swiftclient.utils.generate_temp_url', autospec=True) def test_swift_temp_url_multiple_containers(self, tempurl_mock): self.config(swift_store_multiple_containers_seed=8, @@ -732,6 +792,11 @@ class TestGlanceSwiftTempURL(base.TestCase): self.assertRaises(exception.MissingParameterValue, self.service._validate_temp_url_config) + def test__validate_temp_url_no_account_exception_radosgw(self): + self.config(swift_account=None, group='glance') + self.config(temp_url_endpoint_type='radosgw', group='glance') + self.service._validate_temp_url_config() + def test__validate_temp_url_endpoint_negative_duration(self): self.config(swift_temp_url_duration=-1, group='glance') |