Adding Swift backend Region support
This adds support to configure the region_name for the Swift backend. We need to override the object_storage_url, as the swiftclient does not respect the region_name when using sessions. Change-Id: I13d9b1b6d75f2566622881286d80fba71dbc8af5 Closes-Bug: #1771647
This commit is contained in:
parent
afac47b447
commit
92cb9da7c2
@ -104,6 +104,7 @@ class _ClientWrapper(object):
|
||||
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
self.endpoint = None
|
||||
self.parsed_url = urllib.parse.urlparse(conf.uri)
|
||||
self.session = None
|
||||
|
||||
@ -118,10 +119,19 @@ class _ClientWrapper(object):
|
||||
project_domain_name=self.conf.project_domain_name,
|
||||
auth_url=self.conf.auth_url)
|
||||
self.session = keystone_session.Session(auth=auth)
|
||||
self.endpoint = self.session.get_endpoint(
|
||||
service_type='object-store',
|
||||
interface=self.conf.interface,
|
||||
region_name=self.conf.region_name
|
||||
)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
if self.session is None:
|
||||
self._init_auth()
|
||||
os_options = {
|
||||
'object_storage_url': self.endpoint
|
||||
}
|
||||
client = swiftclient.Connection(session=self.session,
|
||||
insecure=self.conf.insecure)
|
||||
insecure=self.conf.insecure,
|
||||
os_options=os_options)
|
||||
return getattr(client, attr)
|
||||
|
@ -26,6 +26,9 @@ MESSAGE_SWIFT_OPTIONS = (
|
||||
cfg.StrOpt("project_domain_name", help="Domain name containing project"),
|
||||
cfg.StrOpt("user_domain_id", default="default", help="User's domain id"),
|
||||
cfg.StrOpt("user_domain_name", help="User's domain name"),
|
||||
cfg.StrOpt("region_name", help="Region name"),
|
||||
cfg.StrOpt("interface", default="publicURL",
|
||||
help="The default interface for endpoint URL discovery."),
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user