diff options
author | John Estabrook <jestabro@vyos.io> | 2020-02-19 15:56:07 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2020-02-19 17:00:07 -0600 |
commit | 477d056768eb61b38f5236a8a2fdf4ff43b71fd0 (patch) | |
tree | e0267f550bc06dff81374a06c11129687e2c2c52 /src/conf_mode/snmp.py | |
parent | 373fcb829e95b52c6edd5fafd087012988d66c07 (diff) | |
download | vyos-1x-477d056768eb61b38f5236a8a2fdf4ff43b71fd0.tar.gz vyos-1x-477d056768eb61b38f5236a8a2fdf4ff43b71fd0.zip |
snmp: T1769: fix indentation error and add try clause
Diffstat (limited to 'src/conf_mode/snmp.py')
-rwxr-xr-x | src/conf_mode/snmp.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py index 7cffa5e04..ac94afb1a 100755 --- a/src/conf_mode/snmp.py +++ b/src/conf_mode/snmp.py @@ -710,18 +710,20 @@ def apply(snmp): # Passwords are not available immediately in the configuration file, # after daemon startup - we wait until they have been processed by # snmpd, which we see when a magic line appears in this file. - ready = False - while not ready: + while True: while not os.path.exists(config_file_user): sleep(0.5) - ready = True - with open(config_file_user, 'r') as f: - for line in f: - # Search for our magic string inside the file - if 'usmUser' in line: - ready = True - break + try: + with open(config_file_user, 'r') as f: + for line in f: + # Search for our magic string inside the file + if 'usmUser' in line: + break + except IOError: + continue + else: + break # net-snmp is now regenerating the configuration file in the background # thus we need to re-open and re-read the file as the content changed. |