summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-19 19:58:29 +0000
committerGerrit Code Review <review@openstack.org>2016-12-19 19:58:29 +0000
commit6982b3c2e5f08d001b53413e6277a09013fd52df (patch)
treee32ab71f02609739f57a3a1e9aef216d0e2940ba
parent042ab6235e8ff01db4b7bd1ad67411ad34faa6b5 (diff)
parente79162423f4855c4bea601ec3e2175fd984a54ad (diff)
downloadglance_store-0.19.0.tar.gz
Merge "Raise exc when using multi-tenant and swift+config"0.19.0
-rw-r--r--glance_store/_drivers/swift/store.py19
-rw-r--r--glance_store/_drivers/swift/utils.py5
-rw-r--r--glance_store/tests/unit/test_swift_store.py19
-rw-r--r--releasenotes/notes/multi-tenant-store-058b67ce5b7f3bd0.yaml9
4 files changed, 50 insertions, 2 deletions
diff --git a/glance_store/_drivers/swift/store.py b/glance_store/_drivers/swift/store.py
index 6c42bf6..572f931 100644
--- a/glance_store/_drivers/swift/store.py
+++ b/glance_store/_drivers/swift/store.py
@@ -294,12 +294,16 @@ in tenant specific Swift accounts. If this is disabled, Glance stores all
images in its own account. More details multi-tenant store can be found at
https://wiki.openstack.org/wiki/GlanceSwiftTenantSpecificStorage
+NOTE: If using multi-tenant swift store, please make sure
+that you do not set a swift configuration file with the
+'swift_store_config_file' option.
+
Possible values:
* True
* False
Related options:
- * None
+ * swift_store_config_file
""")),
cfg.IntOpt('swift_store_multiple_containers_seed',
@@ -697,6 +701,19 @@ class StoreLocation(location.StoreLocation):
def Store(conf):
+ # NOTE(dharinic): Multi-tenant store cannot work with swift config
+ if conf.glance_store.swift_store_multi_tenant:
+ if (conf.glance_store.default_store == 'swift+config' or
+ sutils.is_multiple_swift_store_accounts_enabled(conf)):
+ msg = _("Swift multi-tenant store cannot be configured to "
+ "work with swift+config. The options "
+ "'swift_store_multi_tenant' and "
+ "'swift_store_config_file' are mutually exclusive. "
+ "If you inted to use multi-tenant swift store, please "
+ "make sure that you have not set a swift configuration "
+ "file with the 'swift_store_config_file' option.")
+ raise exceptions.BadStoreConfiguration(store_name="swift",
+ reason=msg)
try:
conf.register_opts(_SWIFT_OPTS + sutils.swift_opts,
group='glance_store')
diff --git a/glance_store/_drivers/swift/utils.py b/glance_store/_drivers/swift/utils.py
index 642f787..720b4d3 100644
--- a/glance_store/_drivers/swift/utils.py
+++ b/glance_store/_drivers/swift/utils.py
@@ -87,12 +87,15 @@ and customized Swift referencing is disabled. Configuring this
option is highly recommended while using Swift storage backend for
image storage as it avoids storage of credentials in the database.
+NOTE: Please do not configure this option if you have set
+``swift_store_multi_tenant`` to ``True``.
+
Possible values:
* String value representing an absolute path on the glance-api
node
Related options:
- * None
+ * swift_store_multi_tenant
""")),
]
diff --git a/glance_store/tests/unit/test_swift_store.py b/glance_store/tests/unit/test_swift_store.py
index 8907a4a..da91f00 100644
--- a/glance_store/tests/unit/test_swift_store.py
+++ b/glance_store/tests/unit/test_swift_store.py
@@ -258,12 +258,26 @@ class SwiftTests(object):
"""Test that single tenant uris work with multi tenant on."""
uri = ("swift://%s:key@auth_address/glance/%s" %
(self.swift_store_user, FAKE_UUID))
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
# NOTE(markwash): ensure the image is found
ctxt = mock.MagicMock()
size = backend.get_size_from_backend(uri, context=ctxt)
self.assertEqual(5120, size)
+ def test_multi_tenant_with_swift_config(self):
+ """
+ Test that Glance does not start when a config file is set on
+ multi-tenant mode
+ """
+ schemes = ['swift', 'swift+config']
+ for s in schemes:
+ self.config(default_store=s,
+ swift_store_config_file='not/none',
+ swift_store_multi_tenant=True)
+ self.assertRaises(exceptions.BadStoreConfiguration,
+ Store, self.conf)
+
def test_get(self):
"""Test a "normal" retrieval of an image in chunks."""
uri = "swift://%s:key@auth_address/glance/%s" % (
@@ -1097,6 +1111,7 @@ class SwiftTests(object):
"""
Test that we can set a public read acl.
"""
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
store = Store(self.conf)
store.configure()
@@ -1112,6 +1127,7 @@ class SwiftTests(object):
"""
Test that we can set read acl for tenants.
"""
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
store = Store(self.conf)
store.configure()
@@ -1129,6 +1145,7 @@ class SwiftTests(object):
"""
Test that we can set write acl for tenants.
"""
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
store = Store(self.conf)
store.configure()
@@ -1147,6 +1164,7 @@ class SwiftTests(object):
def test_get_connection_manager_multi_tenant(self, manager_class):
manager = mock.MagicMock()
manager_class.return_value = manager
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
store = Store(self.conf)
store.configure()
@@ -1177,6 +1195,7 @@ class SwiftTests(object):
mock_identity):
"""Test that keystone client was initialized correctly"""
# initialize store and connection parameters
+ self.config(swift_store_config_file=None)
self.config(swift_store_multi_tenant=True)
store = Store(self.conf)
store.configure()
diff --git a/releasenotes/notes/multi-tenant-store-058b67ce5b7f3bd0.yaml b/releasenotes/notes/multi-tenant-store-058b67ce5b7f3bd0.yaml
new file mode 100644
index 0000000..4d00269
--- /dev/null
+++ b/releasenotes/notes/multi-tenant-store-058b67ce5b7f3bd0.yaml
@@ -0,0 +1,9 @@
+---
+upgrade:
+ - If using Swift in the multi-tenant mode for storing
+ images in Glance, please note that the configuration
+ options ``swift_store_multi_tenant`` and
+ ``swift_store_config_file`` are now mutually exclusive
+ and cannot be configured together. If you intend to
+ use multi-tenant store, please make sure that you have
+ not set a swift configuration file.