Added A1 policy handler, healthcheck handler, sdl handler and alarm
[ric-app/hw-python.git] / src / handler / HealthCheckHandler.py
1 #       Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
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 # ==================================================================================
16
17 import json
18 from ricxappframe.xapp_frame import RMRXapp
19 from ..utils.constants import Constants
20 from ._BaseHandler import _BaseHandler
21 # from ..manager import SdlAlarmManager
22
23
24 class HealthCheckHandler(_BaseHandler):
25
26     def __init__(self, rmr_xapp: RMRXapp, msgtype):
27         super().__init__(rmr_xapp, msgtype)
28         # self.sdl_alarm_mgr = SdlAlarmManager()
29
30     def request_handler(self, rmr_xapp, summary, sbuf):
31         ok = self._rmr_xapp.healthcheck()
32         # self.sdl_alarm_mgr.checkSdl()
33         if ok:
34             payload = b"OK\n"
35         else:
36             payload = b"ERROR [RMR or SDL is unhealthy]\n"
37         self._rmr_xapp.rmr_rts(sbuf, new_payload=payload, new_mtype=Constants.RIC_HEALTH_CHECK_RESP)
38         self._rmr_xapp.rmr_free(sbuf)