add python compatibility module
[optf/has.git] / conductor / conductor / common / __init__.py
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (c) 2015-2017 AT&T Intellectual Property
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 # -------------------------------------------------------------------------
18 #
19
20 """Music - Common Methods"""
21
22 from oslo_log import log as logging
23
24 from conductor.common import db_backend
25 from conductor.common.music import api
26
27 LOG = logging.getLogger(__name__)
28
29
30 def music_api(configuration):
31     """Create or return a Music API instance"""
32
33     configuration = dict(configuration)
34     kwargs = {
35         'host': configuration.get('host'),
36         'port': configuration.get('port'),
37         'version': configuration.get('version'),
38         'replication_factor': configuration.get('replication_factor'),
39     }
40     api_instance = db_backend.get_client(**kwargs)
41
42     # Create the keyspace if necessary
43     # TODO(jdandrea): Use oslo.config with a [music] section
44     # keyspace = conf.music.get('keyspace')
45     # api_instance.create_keyspace(keyspace)
46     return api_instance