deb-sahara/sahara/swift/utils.py
Sergey Lukjanov 1c70740f7d Rework keystone auth_token middleware configs
We're using Sahara-specific configs and there are some other potential
inconsistencies.

* use common OpenStack [keystone_authtoken] section for middleware
  configurations;
* token validator reworked to be consistent with update auth_token
  middleware usage;
* auth_uri is now stored in context for consistency, additonally, it
* provides correct auth_uri in multi process sahara deployment.

Closes-Bug: #1257472
Closes-Bug: #1249063

Change-Id: I5a33ae6269d40dadcd4893b27a937a37e0c74006
2014-06-05 13:45:20 +04:00

38 lines
1.2 KiB
Python

# Copyright (c) 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from six.moves.urllib import parse as urlparse
from sahara import context
CONF = cfg.CONF
SWIFT_INTERNAL_PREFIX = "swift://"
# TODO(mattf): remove support for OLD_SWIFT_INTERNAL_PREFIX
OLD_SWIFT_INTERNAL_PREFIX = "swift-internal://"
SWIFT_URL_SUFFIX_START = '.'
SWIFT_URL_SUFFIX = SWIFT_URL_SUFFIX_START + 'sahara'
def retrieve_auth_url():
"""This function return auth url v2.0 api. Hadoop Swift library doesn't
support keystone v3 api.
"""
info = urlparse.urlparse(context.current().auth_uri)
return "%s://%s:%s/%s/" % (info.scheme, info.hostname, info.port, 'v2.0')