diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-06-27 14:58:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 14:58:29 +0200 |
commit | 4aca048919b2237ce065bf22a775d782e780ff5a (patch) | |
tree | 8e9de4aeceba264e3d17f2a385a0e442cbab89de /python | |
parent | 1d97d52120eaa33a3c2edb39e966002dab7f9576 (diff) | |
parent | adfb4c81a41b9eec4b33a27a8d8db7184dbda6da (diff) | |
download | vyos-1x-4aca048919b2237ce065bf22a775d782e780ff5a.tar.gz vyos-1x-4aca048919b2237ce065bf22a775d782e780ff5a.zip |
Merge pull request #480 from c-po/t2653
ifconfig: T2653: move macsec interface to get_config_dict()
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configdict.py | 2 | ||||
-rw-r--r-- | python/vyos/configverify.py | 19 | ||||
-rw-r--r-- | python/vyos/ifconfig/interface.py | 3 |
3 files changed, 15 insertions, 9 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 074dc0131..0dc7578d8 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -96,6 +96,8 @@ def dict_merge(source, destination): for key, value in source.items(): if key not in tmp.keys(): tmp[key] = value + elif isinstance(source[key], dict): + tmp[key] = dict_merge(source[key], tmp[key]) return tmp 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)) diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index a9af6ffdf..1819ffc82 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -796,6 +796,3 @@ class Interface(Control): # Interface administrative state state = 'down' if 'disable' in config.keys() else 'up' self.set_admin_state(state) - - import pprint - pprint.pprint(config) |