From 46f0d1ab389984f8f18714db15a01fa6d27fd5bb Mon Sep 17 00:00:00 2001 From: DanielPerkins7 Date: Wed, 2 Aug 2023 15:03:38 +0000 Subject: [PATCH] adds loop to fix len(dns) - fixed. issue 79 resolve #79 --- ssm/agents.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ssm/agents.py b/ssm/agents.py index c9574fb5..a8ce5553 100644 --- a/ssm/agents.py +++ b/ssm/agents.py @@ -369,9 +369,24 @@ def get_dns(dn_file, log): dns.append(line.strip()) else: log.warning('DN in incorrect format: %s', line) + + # If no valid DNs, SSM cannot receive any messages. + if len(dns) == 0: + fails = 0 + while fails < 3 and len(dns) == 0: + for line in lines: + if line.isspace() or line.strip().startswith('#'): + continue + elif line.strip().startswith('/'): + dns.append(line.strip()) + else: + log.warning('DN in incorrect format: %s', line) + if len(dns) == 0: + raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) finally: if f is not None: f.close() +<<<<<<< Updated upstream # If no valid DNs, SSM cannot receive any messages. if len(dns) == 0: fails = 0 @@ -389,6 +404,8 @@ def get_dns(dn_file, log): finally: if f is not None: f.close() +======= +>>>>>>> Stashed changes log.debug('%s DNs found.', len(dns)) return dns