summaryrefslogtreecommitdiff
path: root/src/conf_mode/snmp.py
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2018-09-02 09:28:36 -0700
committerhagbard <vyosdev@derith.de>2018-09-02 09:28:36 -0700
commitd6679e21bc58a37195b518e6b51bc7a50df1b947 (patch)
treea4208622bfd8f49ec1c75cc07c0ae46fde13049a /src/conf_mode/snmp.py
parent228a3beec9d1fadd91b73b8547caec93c8e009f1 (diff)
parentc49ec1392ba68a20af13c21f8a739d7b1dbc4906 (diff)
downloadvyos-1x-d6679e21bc58a37195b518e6b51bc7a50df1b947.tar.gz
vyos-1x-d6679e21bc58a37195b518e6b51bc7a50df1b947.zip
Merge remote-tracking branch 'upstream/current' into T793
Diffstat (limited to 'src/conf_mode/snmp.py')
-rwxr-xr-xsrc/conf_mode/snmp.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index a4e776d49..3eb2935be 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -21,7 +21,6 @@ import os
import shutil
import stat
import pwd
-import time
import jinja2
import random
@@ -771,9 +770,17 @@ def apply(snmp):
# start SNMP daemon
os.system("sudo systemctl restart snmpd.service")
- # the passwords are not available immediately so this is a workaround
- # and should be changed to polling
- time.sleep(2)
+ # 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.
+ snmpReady = False
+ while not snmpReady:
+ with open(config_file_user, 'r') as f:
+ for line in f:
+ # Search for our magic string inside the file
+ if '**** DO NOT EDIT THIS FILE ****' in line:
+ snmpReady = True
+ break
# Back in the Perl days the configuration was re-read and any
# plaintext password inside the configuration was replaced by