Add subscription and notification for resource changes; fix a bug while pserver node...
[pti/o2.git] / mock_smo / mock_smo / config.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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 implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 import os
16
17 import mock_smo.logging as logging
18 logger = logging.get_logger(__name__)
19
20
21 def get_mock_smo_api_url():
22     host = os.environ.get("API_HOST", "localhost")
23     port = 5001 if host == "localhost" else 80
24     return f"http://{host}:{port}"
25
26
27 def get_root_api_base():
28     return "/"
29
30
31 def get_o2ims_api_base():
32     return get_root_api_base() + 'o2ims_infrastructureInventory/v1'
33
34
35 def get_o2dms_api_base():
36     return get_root_api_base() + "o2dms"
37
38
39 def get_redis_host_and_port():
40     host = os.environ.get("REDIS_HOST", "localhost")
41     port = 63792 if host == "localhost" else 6379
42     return dict(host=host, port=port)
43
44
45 def get_smo_o2endpoint():
46     smo_o2endpoint = os.environ.get(
47         "SMO_O2_ENDPOINT", "http://localhost/smo_sim")
48     return smo_o2endpoint