1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2018-2019 Nokia.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 # platform project (RICP).
22 """The module provides implementation of Shared Data Layer (SDL) configurability."""
24 from collections import namedtuple
27 class _Configuration():
28 """This class implements Shared Data Layer (SDL) configurability."""
29 Params = namedtuple('Params', ['db_host', 'db_port', 'db_sentinel_port',
30 'db_sentinel_master_name'])
33 self.params = self._read_configuration()
38 "DB host": self.params.db_host,
39 "DB port": self.params.db_port,
40 "DB master sentinel": self.params.db_sentinel_master_name,
41 "DB sentinel port": self.params.db_sentinel_port
46 """Return SDL configuration."""
50 def _read_configuration(cls):
51 return _Configuration.Params(db_host=os.getenv('DBAAS_SERVICE_HOST'),
52 db_port=os.getenv('DBAAS_SERVICE_PORT'),
53 db_sentinel_port=os.getenv('DBAAS_SERVICE_SENTINEL_PORT'),
54 db_sentinel_master_name=os.getenv('DBAAS_MASTER_NAME'))