summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-06-27 12:36:46 +0200
committerChristian Poessinger <christian@poessinger.com>2020-06-27 12:45:08 +0200
commitcbc293c31709af86af07f03a60818136eeef84fb (patch)
treee1e4abdafe9ae249fedd6ad886f2404c6732a7a5 /python/vyos
parent2f96eee421df9580b112bd1485624e7c9fbceca9 (diff)
downloadvyos-1x-cbc293c31709af86af07f03a60818136eeef84fb.tar.gz
vyos-1x-cbc293c31709af86af07f03a60818136eeef84fb.zip
ifconfig: T2653: add vyos.configverify.verify_source_interface() helper
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configverify.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py
index 64eb80728..e2fffeca7 100644
--- a/python/vyos/configverify.py
+++ b/python/vyos/configverify.py
@@ -21,14 +21,14 @@
# NOTE: imports should be as local as possible to the function which
# makes use of it!
+from vyos import ConfigError
+
def verify_bridge_vrf(config):
"""
Common helper function used by interface implementations to
perform recurring validation of VRF configuration
"""
from netifaces import interfaces
- from vyos import ConfigError
-
if 'vrf' in config.keys():
if config['vrf'] not in interfaces():
raise ConfigError('VRF "{vrf}" does not exist'.format(**config))
@@ -45,8 +45,6 @@ def verify_bridge_address(config):
perform recurring validation of IP address assignmenr
when interface also is part of a bridge.
"""
- from vyos import ConfigError
-
if {'is_bridge_member', 'address'} <= set(config):
raise ConfigError(
f'Cannot assign address to interface "{ifname}" as it is a '
@@ -59,9 +57,18 @@ def verify_bridge_delete(config):
perform recurring validation of IP address assignmenr
when interface also is part of a bridge.
"""
- from vyos import ConfigError
-
if 'is_bridge_member' in config.keys():
raise ConfigError(
'Interface "{ifname}" cannot be deleted as it is a '
'member of bridge "{is_bridge_member}"!'.format(**config))
+
+
+def verify_source_interface(config):
+ """
+ Common helper function used by interface implementations to
+ perform recurring validation of the existence of a source-interface
+ required by e.g. peth/MACvlan, MACsec ...
+ """
+ if not 'source_interface' in config.keys():
+ raise ConfigError('Physical source-interface required for '
+ 'interface "{ifname}"'.format(**config))