Skip to content

Commit

Permalink
adds loop to fix len(dns). issue 79
Browse files Browse the repository at this point in the history
resolve apel#79 . i have just looped everything in the try statement although i am not sure if it is whats needed.
  • Loading branch information
DanielPerkins7 committed Aug 4, 2023
1 parent a5f261e commit db0d6af
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,23 @@ 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()
# If no valid DNs, SSM cannot receive any messages.
if len(dns) == 0:
raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file)

log.debug('%s DNs found.', len(dns))
return dns

0 comments on commit db0d6af

Please sign in to comment.