X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_policy_module%2Fhealing%2Fservice.py;h=4376852812a2d620972387456c223063d61f2fbe;hb=bb6bdfab64270428f29dfa0f03d9b7c35c9faa90;hp=7c6739cbe3e174bbaf728f36ff0d2af3bbe7403e;hpb=d37c54c64eec65c9a3c490a31eef3a02a76cb474;p=osm%2FPOL.git diff --git a/osm_policy_module/healing/service.py b/osm_policy_module/healing/service.py index 7c6739c..4376852 100644 --- a/osm_policy_module/healing/service.py +++ b/osm_policy_module/healing/service.py @@ -238,45 +238,48 @@ class HealingService: database.db.connect() try: if status == "alarm": - with database.db.atomic(): - alarm = HealingActionRepository.get( - HealingAction.alarm_uuid == alarm_uuid - ) - vnf_member_index = alarm.vnf_member_index - vdur_name = alarm.vdur_name - vdu_id = alarm.vdu_id - nsr_id = alarm.nsr_id - heal_type = alarm.recovery_action - cooldown_time = alarm.cooldown_time - count_index = alarm.count_index - last_heal = alarm.last_heal - day1 = alarm.day1 - vnfinstance_id = alarm.vnfinstance_id - alarms = HealingActionRepository.list( - HealingAction.vnf_member_index == vnf_member_index, - HealingAction.vdur_name == vdur_name, - ) - statuses = [] + if self.conf.get("autoheal", "enabled") == "True": + with database.db.atomic(): + alarm = HealingActionRepository.get( + HealingAction.alarm_uuid == alarm_uuid + ) + vnf_member_index = alarm.vnf_member_index + vdur_name = alarm.vdur_name + vdu_id = alarm.vdu_id + nsr_id = alarm.nsr_id + heal_type = alarm.recovery_action + cooldown_time = alarm.cooldown_time + count_index = alarm.count_index + last_heal = alarm.last_heal + day1 = alarm.day1 + vnfinstance_id = alarm.vnfinstance_id + alarms = HealingActionRepository.list( + HealingAction.vnf_member_index == vnf_member_index, + HealingAction.vdur_name == vdur_name, + ) + statuses = [] - for alarm in alarms: - statuses.append(alarm.last_status) - if (set(statuses) == {"alarm"}) or ("alarm" in statuses): - delta = datetime.datetime.now() - last_heal - if delta.total_seconds() > cooldown_time: - await self.lcm_client.heal( - nsr_id, - vnfinstance_id, - vdur_name, - vdu_id, - vnf_member_index, - heal_type, - day1, - count_index, - ) - last_heal = datetime.datetime.now() - log.info("datetime.datetime.now %s", datetime.datetime.now) - alarm.last_heal = last_heal - alarm.save() + for alarm in alarms: + statuses.append(alarm.last_status) + if (set(statuses) == {"alarm"}) or ("alarm" in statuses): + delta = datetime.datetime.now() - last_heal + if delta.total_seconds() > cooldown_time: + await self.lcm_client.heal( + nsr_id, + vnfinstance_id, + vdur_name, + vdu_id, + vnf_member_index, + heal_type, + day1, + count_index, + ) + last_heal = datetime.datetime.now() + log.info( + "datetime.datetime.now %s", datetime.datetime.now + ) + alarm.last_heal = last_heal + alarm.save() except HealingAction.DoesNotExist: log.info("There is no healing action configured for alarm %s.", alarm_uuid)