Add region configuration for swift
Addresses bug 1050034 Change-Id: Ib83f5dbb2c1fbeacd741e0cb92b619e67b2243c7
This commit is contained in:
parent
7e3ecc2517
commit
173d821463
@ -231,6 +231,10 @@ swift_enable_snet = False
|
|||||||
# containers created by Glance in multi-tenant mode.
|
# containers created by Glance in multi-tenant mode.
|
||||||
#swift_store_admin_tenants = []
|
#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 =============================
|
# ============ S3 Store Options =============================
|
||||||
|
|
||||||
# Address where the S3 authentication service lives
|
# Address where the S3 authentication service lives
|
||||||
|
@ -51,6 +51,7 @@ swift_opts = [
|
|||||||
cfg.StrOpt('swift_store_user', secret=True),
|
cfg.StrOpt('swift_store_user', secret=True),
|
||||||
cfg.StrOpt('swift_store_key', secret=True),
|
cfg.StrOpt('swift_store_key', secret=True),
|
||||||
cfg.StrOpt('swift_store_auth_version', default='2'),
|
cfg.StrOpt('swift_store_auth_version', default='2'),
|
||||||
|
cfg.StrOpt('swift_store_region'),
|
||||||
cfg.StrOpt('swift_store_container',
|
cfg.StrOpt('swift_store_container',
|
||||||
default=DEFAULT_CONTAINER),
|
default=DEFAULT_CONTAINER),
|
||||||
cfg.IntOpt('swift_store_large_object_size',
|
cfg.IntOpt('swift_store_large_object_size',
|
||||||
@ -218,6 +219,7 @@ class Store(glance.store.base.Store):
|
|||||||
self.snet = CONF.swift_enable_snet
|
self.snet = CONF.swift_enable_snet
|
||||||
self.multi_tenant = CONF.swift_store_multi_tenant
|
self.multi_tenant = CONF.swift_store_multi_tenant
|
||||||
self.admin_tenants = CONF.swift_store_admin_tenants
|
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.auth_version = self._option_get('swift_store_auth_version')
|
||||||
self.storage_url = None
|
self.storage_url = None
|
||||||
self.token = None
|
self.token = None
|
||||||
@ -330,7 +332,7 @@ class Store(glance.store.base.Store):
|
|||||||
def _swift_connection_for_location(self, loc):
|
def _swift_connection_for_location(self, loc):
|
||||||
if loc.user:
|
if loc.user:
|
||||||
return self._make_swift_connection(
|
return self._make_swift_connection(
|
||||||
loc.swift_url, loc.user, loc.key)
|
loc.swift_url, loc.user, loc.key, region=self.region)
|
||||||
else:
|
else:
|
||||||
if self.multi_tenant:
|
if self.multi_tenant:
|
||||||
return self._make_swift_connection(
|
return self._make_swift_connection(
|
||||||
@ -341,8 +343,8 @@ class Store(glance.store.base.Store):
|
|||||||
LOG.error(reason)
|
LOG.error(reason)
|
||||||
raise exception.BadStoreUri(message=reason)
|
raise exception.BadStoreUri(message=reason)
|
||||||
|
|
||||||
def _make_swift_connection(self, auth_url, user, key, storage_url=None,
|
def _make_swift_connection(self, auth_url, user, key, region=None,
|
||||||
token=None):
|
storage_url=None, token=None):
|
||||||
"""
|
"""
|
||||||
Creates a connection using the Swift client library.
|
Creates a connection using the Swift client library.
|
||||||
|
|
||||||
@ -350,6 +352,7 @@ class Store(glance.store.base.Store):
|
|||||||
v2 style Keystone auth.
|
v2 style Keystone auth.
|
||||||
:param user A string containing the tenant:user information.
|
:param user A string containing the tenant:user information.
|
||||||
:param key A string containing the key/password for the connection.
|
: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 storage_url A string containing the storage URL.
|
||||||
:param token A string containing the token
|
:param token A string containing the token
|
||||||
"""
|
"""
|
||||||
@ -377,8 +380,11 @@ class Store(glance.store.base.Store):
|
|||||||
None, user, None, preauthurl=storage_url, preauthtoken=token,
|
None, user, None, preauthurl=storage_url, preauthtoken=token,
|
||||||
snet=snet, tenant_name=tenant_name, auth_version='2')
|
snet=snet, tenant_name=tenant_name, auth_version='2')
|
||||||
else:
|
else:
|
||||||
|
os_options = {}
|
||||||
|
if region:
|
||||||
|
os_options['region_name'] = region
|
||||||
return swiftclient.Connection(
|
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)
|
tenant_name=tenant_name, auth_version=auth_version)
|
||||||
|
|
||||||
def _option_get(self, param):
|
def _option_get(self, param):
|
||||||
|
@ -20,7 +20,7 @@ iso8601>=0.1.4
|
|||||||
|
|
||||||
|
|
||||||
# For Swift storage backend.
|
# For Swift storage backend.
|
||||||
python-swiftclient>=1,<2
|
python-swiftclient>=1.2,<2
|
||||||
|
|
||||||
# Note you will need gcc buildtools installed and must
|
# Note you will need gcc buildtools installed and must
|
||||||
# have installed libxml headers for lxml to be successfully
|
# have installed libxml headers for lxml to be successfully
|
||||||
|
Loading…
Reference in New Issue
Block a user