1
# Copyright (c) 2013 Mirantis Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
18
from oslo.config import cfg
20
from sahara import context
21
from sahara.i18n import _LI
22
from sahara.swift import utils as su
23
from sahara.utils import xmlutils as x
26
LOG = logging.getLogger(__name__)
28
HADOOP_SWIFT_AUTH_URL = 'fs.swift.service.sahara.auth.url'
29
HADOOP_SWIFT_TENANT = 'fs.swift.service.sahara.tenant'
30
HADOOP_SWIFT_USERNAME = 'fs.swift.service.sahara.username'
31
HADOOP_SWIFT_PASSWORD = 'fs.swift.service.sahara.password'
32
HADOOP_SWIFT_REGION = 'fs.swift.service.sahara.region'
35
def retrieve_tenant():
36
return context.current().tenant_name
39
def get_swift_configs():
40
configs = x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')
42
if conf['name'] == HADOOP_SWIFT_AUTH_URL:
43
conf['value'] = su.retrieve_auth_url() + "tokens/"
44
if conf['name'] == HADOOP_SWIFT_TENANT:
45
conf['value'] = retrieve_tenant()
46
if CONF.os_region_name and conf['name'] == HADOOP_SWIFT_REGION:
47
conf['value'] = CONF.os_region_name
49
result = [cfg for cfg in configs if cfg['value']]
50
LOG.info(_LI("Swift would be integrated with the following "
51
"params: %s"), result)