summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-10-27 23:04:59 +0100
committerChristian Poessinger <christian@poessinger.com>2019-10-27 23:59:47 +0100
commitb666ec971486810e0f0a19a9cc411642c79e28fc (patch)
tree9b0bd49316273fdf8dce3babdb299ce8da1e6f4b
parentc9b892349bac27fad9e2336e2020c589759598a1 (diff)
downloadvyos-1x-b666ec971486810e0f0a19a9cc411642c79e28fc.tar.gz
vyos-1x-b666ec971486810e0f0a19a9cc411642c79e28fc.zip
snmp: T1738: cleanup import statements
(cherry picked from commit b86f1d702e3b67774d3a2eec1f9fa83108711798)
-rwxr-xr-xsrc/conf_mode/snmp.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 929e9b446..fbffce751 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -16,19 +16,17 @@
import sys
import os
-import shutil
import stat
import pwd
-import time
-
import jinja2
-import random
-import binascii
import re
import vyos.version
import vyos.validate
+from binascii import hexlify
+from shutil import move
+from time import sleep
from vyos.config import Config
from vyos import ConfigError
@@ -249,10 +247,10 @@ def get_config():
version_data = vyos.version.get_version_data()
snmp['version'] = version_data['version']
- # create an internal snmpv3 user of the form 'vyattaxxxxxxxxxxxxxxxx'
+ # create an internal snmpv3 user of the form 'vyosxxxxxxxxxxxxxxxx'
# os.urandom(8) returns 8 bytes of random data
- snmp['vyos_user'] = 'vyatta' + binascii.hexlify(os.urandom(8)).decode('utf-8')
- snmp['vyos_user_pass'] = binascii.hexlify(os.urandom(16)).decode('utf-8')
+ snmp['vyos_user'] = 'vyos' + hexlify(os.urandom(8)).decode('utf-8')
+ snmp['vyos_user_pass'] = hexlify(os.urandom(16)).decode('utf-8')
if conf.exists('community'):
for name in conf.list_nodes('community'):
@@ -700,7 +698,7 @@ def apply(snmp):
if os.path.exists(volatiledir) and os.path.isdir(volatiledir):
files = os.listdir(volatiledir)
for f in files:
- shutil.move(volatiledir + '/' + f, nonvolatiledir)
+ move(volatiledir + '/' + f, nonvolatiledir)
os.chmod(nonvolatiledir + '/' + f, stat.S_IWUSR | stat.S_IRUSR)
os.rmdir(volatiledir)
@@ -721,7 +719,7 @@ def apply(snmp):
snmpReady = False
while not snmpReady:
while not os.path.exists(config_file_user):
- time.sleep(1)
+ sleep(1)
with open(config_file_user, 'r') as f:
for line in f: