From 2a265e4fea1153c928904eaadc3577dd38e1a75e Mon Sep 17 00:00:00 2001 From: Vitaliy Kharechko Date: Wed, 18 May 2016 14:36:04 +0300 Subject: [PATCH] Gracefully handle missing stacklight configuration Change-Id: Ia369ce26ccff4c7f1cfeaab0634cec3e5391f081 --- .../config/broadviewcollector.conf | 1 + broadview_collector/plugins/stacklight.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/broadview_collector/config/broadviewcollector.conf b/broadview_collector/config/broadviewcollector.conf index baef5bc..01ce729 100644 --- a/broadview_collector/config/broadviewcollector.conf +++ b/broadview_collector/config/broadviewcollector.conf @@ -53,4 +53,5 @@ port: 8082 #ip_address: 172.16.170.184 #port: 8088 +#timeout: 1.0 diff --git a/broadview_collector/plugins/stacklight.py b/broadview_collector/plugins/stacklight.py index 38f0789..c513bd2 100644 --- a/broadview_collector/plugins/stacklight.py +++ b/broadview_collector/plugins/stacklight.py @@ -31,11 +31,20 @@ class BroadViewPublisher(BroadViewPublisherBase): try: bvcfg = ConfigParser.ConfigParser() bvcfg.read("/etc/broadviewcollector.conf") - self._ipaddr = bvcfg.get("stacklight", "ip_address") - self._port = bvcfg.get("stacklight", "port") - self._timeout = bvcfg.get("stacklight", "timeout") + try: + self._ipaddr = bvcfg.get("stacklight", "ip_address") + except: + LOG.info("BroadViewPublisher: unable to read stacklight ip_address") + try: + self._port = bvcfg.get("stacklight", "port") + except: + LOG.info("BroadViewPublisher: unable to read stacklight port") + try: + self._timeout = bvcfg.get("stacklight", "timeout") + except: + LOG.info("BroadViewPublisher: unable to read stacklight timeout") except: - LOG.error("BroadViewPublisher: unable to read configuration") + LOG.error("BroadViewPublisher: unable to read stacklight configuration") def __init__(self): self.readConfig()