Skip to content

Commit

Permalink
Merge pull request #695 from Alignak-monitoring/fix-#694
Browse files Browse the repository at this point in the history
For #694: catch KeyError exception and raise an ERROR log
  • Loading branch information
ddurieux authored Jan 14, 2017
2 parents 88f7820 + d4b3717 commit 7d7f097
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions alignak/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def retention_load(self):
"""
self.hook_point('load_retention')

def get_retention_data(self): # pylint: disable=R0912
def get_retention_data(self): # pylint: disable=R0912,too-many-statements
"""Get all host and service data in order to store it after
The module is in charge of that
Expand Down Expand Up @@ -1332,8 +1332,13 @@ def get_retention_data(self): # pylint: disable=R0912
# manage special properties: the comments
if 'comments' in h_dict and h_dict['comments'] != []:
comments = []
for comment_uuid in h_dict['comments']:
comments.append(self.comments[comment_uuid].serialize())
try:
for comment_uuid in h_dict['comments']:
comments.append(self.comments[comment_uuid].serialize())
except KeyError as exp:
logger.error("Saving host %s retention, "
"missing comment in the global comments", host.host_name)
logger.exception("Exception: %s", exp)
h_dict['comments'] = comments
# manage special properties: the notified_contacts
if 'notified_contacts' in h_dict and h_dict['notified_contacts'] != []:
Expand Down Expand Up @@ -1770,7 +1775,7 @@ def update_downtimes_and_comments(self):
# which were marked for deletion (mostly by dt.exit())
for downtime in self.downtimes.values():
if downtime.can_be_deleted is True:
logger.error("Downtime to delete: %s", downtime.__dict__)
logger.info("Downtime to delete: %s", downtime.__dict__)
ref = self.find_item_by_id(downtime.ref)
self.del_downtime(downtime.uuid)
broks.append(ref.get_update_status_brok())
Expand Down

0 comments on commit 7d7f097

Please sign in to comment.