summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-18 20:24:54 +0200
committerGitHub <noreply@github.com>2020-05-18 20:24:54 +0200
commit6e77c5b73eb040e3a9adb35b10c42ea2117f655a (patch)
tree5851f1adf33c18f94a16c71f8b01175e0d43e428
parent1e4dd009d711f24c504e0a6b61c5aefd37dcd6ce (diff)
parent4d0c5c848fda305055b71abf63ccd18478586694 (diff)
downloadvyos-1x-6e77c5b73eb040e3a9adb35b10c42ea2117f655a.tar.gz
vyos-1x-6e77c5b73eb040e3a9adb35b10c42ea2117f655a.zip
Merge pull request #412 from thomas-mangin/T2475
flake8: T2475: fix a number of issue reported by flake8
-rw-r--r--python/vyos/component_versions.py2
-rw-r--r--python/vyos/dicts.py3
-rw-r--r--python/vyos/validate.py2
-rwxr-xr-xsrc/conf_mode/interfaces-tunnel.py4
-rwxr-xr-xsrc/conf_mode/ipsec-settings.py2
-rwxr-xr-xsrc/op_mode/show_interfaces.py6
6 files changed, 10 insertions, 9 deletions
diff --git a/python/vyos/component_versions.py b/python/vyos/component_versions.py
index ec54a1576..90b458aae 100644
--- a/python/vyos/component_versions.py
+++ b/python/vyos/component_versions.py
@@ -51,7 +51,7 @@ def get_component_versions_from_file(config_file_name='/opt/vyatta/etc/config/co
"""
f = open(config_file_name, 'r')
for line_in_config in f:
- component_version = return_version(line_in_config)
+ component_version = get_component_version(line_in_config)
if component_version:
return component_version
raise ValueError("no config string in file:", config_file_name)
diff --git a/python/vyos/dicts.py b/python/vyos/dicts.py
index 79cab4a08..b12cda40f 100644
--- a/python/vyos/dicts.py
+++ b/python/vyos/dicts.py
@@ -15,6 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from vyos import ConfigError
+
+
class FixedDict(dict):
"""
FixedDict: A dictionnary not allowing new keys to be created after initialisation.
diff --git a/python/vyos/validate.py b/python/vyos/validate.py
index e083604c5..6304fa8de 100644
--- a/python/vyos/validate.py
+++ b/python/vyos/validate.py
@@ -205,7 +205,7 @@ def assert_number(n):
def assert_positive(n, smaller=0):
assert_number(n)
if int(n) < smaller:
- raise ValueError(f'{n} is smaller than {limit}')
+ raise ValueError(f'{n} is smaller than {smaller}')
def assert_mtu(mtu, min=68, max=9000):
diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py
index 5261b6e7d..8e9bb069e 100755
--- a/src/conf_mode/interfaces-tunnel.py
+++ b/src/conf_mode/interfaces-tunnel.py
@@ -222,7 +222,7 @@ class ConfigurationState(Config):
remove all the values which were not changed from the default
"""
for option in options:
- if self.exists(option) and self_return_value(option) != self.default[option]:
+ if self.exists(option) and self.self_return_value(option) != self.default[option]:
continue
del self.options[option]
@@ -555,7 +555,7 @@ def verify(conf):
# source-interface check
if tun_dev and tun_dev not in options['interfaces']:
- raise ConfigError(f'device "{dev}" does not exist')
+ raise ConfigError(f'device "{tun_dev}" does not exist')
# tunnel encapsulation check
diff --git a/src/conf_mode/ipsec-settings.py b/src/conf_mode/ipsec-settings.py
index 3398bcdf2..6282c2cc7 100755
--- a/src/conf_mode/ipsec-settings.py
+++ b/src/conf_mode/ipsec-settings.py
@@ -99,7 +99,7 @@ def get_config():
def write_ipsec_secrets(c):
if c.get("ipsec_l2tp_auth_mode") == "pre-shared-secret":
secret_txt = "{0}\n{1} %any : PSK \"{2}\"\n{3}\n".format(delim_ipsec_l2tp_begin, c['outside_addr'], c['ipsec_l2tp_secret'], delim_ipsec_l2tp_end)
- elif data.get("ipsec_l2tp_auth_mode") == "x509":
+ elif c.get("ipsec_l2tp_auth_mode") == "x509":
secret_txt = "{0}\n: RSA {1}\n{2}\n".format(delim_ipsec_l2tp_begin, c['server_key_file_copied'], delim_ipsec_l2tp_end)
old_umask = os.umask(0o077)
diff --git a/src/op_mode/show_interfaces.py b/src/op_mode/show_interfaces.py
index 7041c7e16..2f0f8a1c9 100755
--- a/src/op_mode/show_interfaces.py
+++ b/src/op_mode/show_interfaces.py
@@ -267,17 +267,15 @@ def run_show_counters(ifnames, iftypes, vif, vrrp):
@register('clear')
-def run_clear_intf(intf, iftypes, vif, vrrp):
+def run_clear_intf(ifnames, iftypes, vif, vrrp):
for interface in filtered_interfaces(ifnames, iftypes, vif, vrrp):
print(f'Clearing {interface.ifname}')
- interface = Interface(ifname, create=False, debug=False)
interface.operational.clear_counters()
@register('reset')
-def run_reset_intf(intf, iftypes, vif, vrrp):
+def run_reset_intf(ifnames, iftypes, vif, vrrp):
for interface in filtered_interfaces(ifnames, iftypes, vif, vrrp):
- interface = Interface(ifname, create=False, debug=False)
interface.operational.reset_counters()