summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-08 18:18:42 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-08 18:18:42 +0100
commit43a9441cb80a14fff791bbd89e88a3c2ac99e3ab (patch)
tree2bf9c09fab5c95efa73fc2f7601890466fa9b99f /python/vyos
parent13a58d38b3dc8065a8ba71904e143e3d69aab638 (diff)
parent23f55c4bcbe5475ed98d57cf54b645ef0c2cc1a8 (diff)
downloadvyos-1x-43a9441cb80a14fff791bbd89e88a3c2ac99e3ab.tar.gz
vyos-1x-43a9441cb80a14fff791bbd89e88a3c2ac99e3ab.zip
Merge branch 'current' of github.com:vyos/vyos-1x into equuleus
* 'current' of github.com:vyos/vyos-1x: (30 commits) smoketest: dummy: fix indent smoketest: bridge: bond: enable ip subsystem tests smoketest: interfaces: dhcpv6pd final fix smoketest: ethernet: fix link-speed loop test Debian: add build-dependency on python3-jinja2 smoketest: ethernet: verify() speed/duplex must both be auto or discrete smoketest: interfaces: report skipped tests smoketest: ethernet: bugfixes for dhcpc6 and unknown interfaces Debian: add python3-psutil build dependency smoketest: ethernet: check for error on non existing interface vyos.configverify: provide generic helper to check for interface existence smoketest: interfaces: fix dhcpv6 pd testcase when using multiple interfaces login: radius: T3192: migrate to get_config_dict() ssh: T2635: harden Jinja2 template and daemon startup ssh: T2635: change sshd_config path to /run/sshd login: radius: T3192: support IPv6 server(s) and source-address xml: include: provide generic include for disable node xml: radius: T3192: split individual nodes to discrete includes bgp: T2174: verify() existence of route-map and prefix-list smoketest: interfaces: test dhcpv6 pd sla-id auto increment ...
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configverify.py19
-rw-r--r--python/vyos/ifconfig/interface.py2
-rw-r--r--python/vyos/util.py2
3 files changed, 12 insertions, 11 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index a425ca671..bcaec55be 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -136,15 +136,14 @@ def verify_bridge_delete(config):
'Interface "{ifname}" cannot be deleted as it is a '
'member of bridge "{is_bridge_member}"!'.format(**config))
-def verify_interface_exists(config):
+def verify_interface_exists(ifname):
"""
Common helper function used by interface implementations to perform
recurring validation if an interface actually exists.
"""
from netifaces import interfaces
- if not config['ifname'] in interfaces():
- raise ConfigError('Interface "{ifname}" does not exist!'
- .format(**config))
+ if ifname not in interfaces():
+ raise ConfigError(f'Interface "{ifname}" does not exist!')
def verify_source_interface(config):
"""
@@ -187,15 +186,17 @@ def verify_dhcpv6(config):
# assigned IPv6 subnet from a delegated prefix
for pd in dict_search('dhcpv6_options.pd', config):
sla_ids = []
+ interfaces = dict_search(f'dhcpv6_options.pd.{pd}.interface', config)
- if not dict_search(f'dhcpv6_options.pd.{pd}.interface', config):
+ if not interfaces:
raise ConfigError('DHCPv6-PD requires an interface where to assign '
'the delegated prefix!')
- for interface in dict_search(f'dhcpv6_options.pd.{pd}.interface', config):
- sla_id = dict_search(
- f'dhcpv6_options.pd.{pd}.interface.{interface}.sla_id', config)
- sla_ids.append(sla_id)
+ for count, interface in enumerate(interfaces):
+ if 'sla_id' in interfaces[interface]:
+ sla_ids.append(interfaces[interface]['sla_id'])
+ else:
+ sla_ids.append(str(count))
# Check for duplicates
duplicates = [x for n, x in enumerate(sla_ids) if x in sla_ids[:n]]
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 35a964110..4c05ac613 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -265,7 +265,7 @@ class Interface(Control):
# If we can not connect to the interface then let the caller know
# as the class could not be correctly initialised
else:
- raise Exception('interface "{}" not found'.format(self.config['ifname']))
+ raise Exception(f'interface "{ifname}" not found!')
# temporary list of assigned IP addresses
self._addr = []
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 494c8155e..699f05892 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -311,7 +311,7 @@ def chmod_755(path):
def makedir(path, user=None, group=None):
if os.path.exists(path):
return
- os.mkdir(path)
+ os.makedirs(path, mode=0o755)
chown(path, user, group)