Gracefully handle missing stacklight configuration

Change-Id: Ia369ce26ccff4c7f1cfeaab0634cec3e5391f081
This commit is contained in:
Vitaliy Kharechko 2016-05-18 14:36:04 +03:00
parent d9c0b5f106
commit 2a265e4fea
2 changed files with 14 additions and 4 deletions

View File

@ -53,4 +53,5 @@ port: 8082
#ip_address: 172.16.170.184
#port: 8088
#timeout: 1.0

View File

@ -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()