Trivial: use condition instead of try/except

When getting a service's config, stop using try/except to tell if the
conf exists, and instead use a cleaner `if hasattr`.

Change-Id: Ib98ff29a38dfaaeff144958c3e0ac3c141429ba9
This commit is contained in:
Artom Lifshitz 2020-06-19 09:13:53 -04:00
parent 12eca6f75e
commit 345b440b2b

View File

@ -80,9 +80,8 @@ class ServiceManager(SSHClient):
whitebox-<service> config section.
"""
super(ServiceManager, self).__init__(hostname)
try:
conf = getattr(CONF, 'whitebox-%s' % service)
except AttributeError:
conf = getattr(CONF, 'whitebox-%s' % service, None)
if conf is None:
raise exceptions.MissingServiceSectionException(service=service)
self.config_path = getattr(conf, 'config_path', None)
self.restart_command = getattr(conf, 'restart_command', None)