summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2012-09-11 22:59:52 +0000
committerThierry Carrez <thierry@openstack.org>2012-09-14 10:59:25 +0200
commit812101ae5cdf53a1c6deb294ec92a0ee1e4f3fcc (patch)
tree0cb25218a4e47b46da120306c2fbca880fc99c01
parent0315ad5b961beca9cf51db66fdc98913c4be4cf7 (diff)
downloadglance-folsom-rc1.tar.gz
Add region configuration for swiftfolsom-rc1
Addresses bug 1050034 Change-Id: Ib83f5dbb2c1fbeacd741e0cb92b619e67b2243c7
-rw-r--r--etc/glance-api.conf4
-rw-r--r--glance/store/swift.py14
-rw-r--r--tools/pip-requires2
3 files changed, 15 insertions, 5 deletions
diff --git a/etc/glance-api.conf b/etc/glance-api.conf
index 4dd6e5f55..52ed789b6 100644
--- a/etc/glance-api.conf
+++ b/etc/glance-api.conf
@@ -231,6 +231,10 @@ swift_enable_snet = False
# containers created by Glance in multi-tenant mode.
#swift_store_admin_tenants = []
+# The region of the swift endpoint to be used for single tenant. This setting
+# is only necessary if the tenant has multiple swift endpoints.
+#swift_store_region =
+
# ============ S3 Store Options =============================
# Address where the S3 authentication service lives
diff --git a/glance/store/swift.py b/glance/store/swift.py
index fc3571df6..59f0f57bb 100644
--- a/glance/store/swift.py
+++ b/glance/store/swift.py
@@ -51,6 +51,7 @@ swift_opts = [
cfg.StrOpt('swift_store_user', secret=True),
cfg.StrOpt('swift_store_key', secret=True),
cfg.StrOpt('swift_store_auth_version', default='2'),
+ cfg.StrOpt('swift_store_region'),
cfg.StrOpt('swift_store_container',
default=DEFAULT_CONTAINER),
cfg.IntOpt('swift_store_large_object_size',
@@ -216,6 +217,7 @@ class Store(glance.store.base.Store):
self.snet = CONF.swift_enable_snet
self.multi_tenant = CONF.swift_store_multi_tenant
self.admin_tenants = CONF.swift_store_admin_tenants
+ self.region = CONF.swift_store_region
self.auth_version = self._option_get('swift_store_auth_version')
self.storage_url = None
self.token = None
@@ -328,7 +330,7 @@ class Store(glance.store.base.Store):
def _swift_connection_for_location(self, loc):
if loc.user:
return self._make_swift_connection(
- loc.swift_url, loc.user, loc.key)
+ loc.swift_url, loc.user, loc.key, region=self.region)
else:
if self.multi_tenant:
return self._make_swift_connection(
@@ -339,8 +341,8 @@ class Store(glance.store.base.Store):
LOG.error(reason)
raise exception.BadStoreUri(message=reason)
- def _make_swift_connection(self, auth_url, user, key, storage_url=None,
- token=None):
+ def _make_swift_connection(self, auth_url, user, key, region=None,
+ storage_url=None, token=None):
"""
Creates a connection using the Swift client library.
@@ -348,6 +350,7 @@ class Store(glance.store.base.Store):
v2 style Keystone auth.
:param user A string containing the tenant:user information.
:param key A string containing the key/password for the connection.
+ :param region A string containing the swift endpoint region
:param storage_url A string containing the storage URL.
:param token A string containing the token
"""
@@ -375,8 +378,11 @@ class Store(glance.store.base.Store):
None, user, None, preauthurl=storage_url, preauthtoken=token,
snet=snet, tenant_name=tenant_name, auth_version='2')
else:
+ os_options = {}
+ if region:
+ os_options['region_name'] = region
return swiftclient.Connection(
- full_auth_url, user, key, snet=snet,
+ full_auth_url, user, key, snet=snet, os_options=os_options,
tenant_name=tenant_name, auth_version=auth_version)
def _option_get(self, param):
diff --git a/tools/pip-requires b/tools/pip-requires
index 8464215ed..e873537ec 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -20,7 +20,7 @@ iso8601>=0.1.4
# For Swift storage backend.
-python-swiftclient>=1,<2
+python-swiftclient>=1.2,<2
# Note you will need gcc buildtools installed and must
# have installed libxml headers for lxml to be successfully