From cb3ec75b8062499e8f5b016bb9dfb5419abf4064 Mon Sep 17 00:00:00 2001 From: Ryan Brandt Date: Tue, 9 Feb 2016 14:45:48 -0700 Subject: [PATCH] Fix message parsing when link or lifecycle state is None Change-Id: Ibd826ca4b2ddf2c1ae586b1168cbe642a1028609 --- monasca_persister/persister.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/monasca_persister/persister.py b/monasca_persister/persister.py index 110ee3c9..f3c32f57 100644 --- a/monasca_persister/persister.py +++ b/monasca_persister/persister.py @@ -633,10 +633,18 @@ def parse_alarm_state_hist_message(message): old_state = alarm_transitioned['oldState'] LOG.debug('old state: %s', old_state) - link = alarm_transitioned['link'] if 'link' in alarm_transitioned else "" + # Key may not exist or value may be none, convert both to "" + if 'link' in alarm_transitioned and alarm_transitioned['link'] is not None: + link = alarm_transitioned['link'] + else: + link = "" LOG.debug('link: %s', link) - lifecycle_state = alarm_transitioned['lifecycleState'] if 'lifecycleState' in alarm_transitioned else "" + # Key may not exist or value may be none, convert both to "" + if 'lifecycleState' in alarm_transitioned and alarm_transitioned['lifecycleState'] is not None: + lifecycle_state = alarm_transitioned['lifecycleState'] + else: + lifecycle_state = "" LOG.debug('lifecycle_state: %s', lifecycle_state) state_change_reason = alarm_transitioned[