1 # ==================================================================================
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # ==================================================================================
19 from ricxappframe.xapp_frame import RMRXapp
20 from ricxappframe.alarm import alarm
21 from ._BaseManager import _BaseManager
24 # noinspection PyProtectedMember,PyProtectedMember
25 class SdlAlarmManager(_BaseManager):
27 def __init__(self, rmr_xapp: RMRXapp):
28 super().__init__(rmr_xapp)
29 self.alarm_mgr = alarm.AlarmManager(self._rmr_xapp._mrc, "ric-xapp", "hw-python")
33 if self._rmr_xapp._sdl.healthcheck():
34 # healthy, so clear the alarm if it was raised
36 self.logger.info("SdlAlarmManager:: clearing alarm")
37 self.alarm_mgr.clear_alarm(self.alarm_sdl)
40 # not healthy, so (re-)raise the alarm
41 self.logger.info("SdlAlarmManager:: connection to SDL is not healthy, raising alarm")
43 self.alarm_mgr.reraise_alarm(self.alarm_sdl)
45 self.alarm_sdl = self.alarm_mgr.create_alarm(1, alarm.AlarmSeverity.CRITICAL,
46 "SdlAlarmManager:: SDL failure")
47 self.alarm_mgr.raise_alarm(self.alarm_sdl)
48 self.logger.warning("SdlAlarmManager:: dropping request!")