summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-07-24 17:24:50 +0200
committerChristian Poessinger <christian@poessinger.com>2020-07-25 17:30:12 +0200
commitd81ce482836ab4adf4f71e2b3dc21477db49a9f0 (patch)
tree4bb27889b285bb82c89fefddbfaf7c6a098d97bd /python
parentf81b0443cf09c34cb1f2060094e3eb294b8fa192 (diff)
downloadvyos-1x-d81ce482836ab4adf4f71e2b3dc21477db49a9f0.tar.gz
vyos-1x-d81ce482836ab4adf4f71e2b3dc21477db49a9f0.zip
vlan: ifconfig: T2653: move get_removed_vlans() to vyos.configdiff
As we wrap up additional functions from this library it should be part of it.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configdict.py28
-rw-r--r--python/vyos/ifconfig_vlan.py27
2 files changed, 27 insertions, 28 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index f26b47e41..a1553ae61 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -168,6 +168,33 @@ def node_changed(conf, path):
keys = D.get_child_nodes_diff(path, expand_nodes=Diff.DELETE)['delete'].keys()
return list(keys)
+def get_removed_vlans(conf, dict):
+ """
+ Common function to parse a dictionary retrieved via get_config_dict() and
+ determine any added/removed VLAN interfaces - be it 802.1q or Q-in-Q.
+ """
+ from vyos.configdiff import get_config_diff, Diff
+
+ # Check vif, vif-s/vif-c VLAN interfaces for removal
+ D = get_config_diff(conf, key_mangling=('-', '_'))
+ D.set_level(conf.get_level())
+ # get_child_nodes() will return dict_keys(), mangle this into a list with PEP448
+ keys = D.get_child_nodes_diff(['vif'], expand_nodes=Diff.DELETE)['delete'].keys()
+ if keys:
+ dict.update({'vif_remove': [*keys]})
+
+ # get_child_nodes() will return dict_keys(), mangle this into a list with PEP448
+ keys = D.get_child_nodes_diff(['vif-s'], expand_nodes=Diff.DELETE)['delete'].keys()
+ if keys:
+ dict.update({'vif_s_remove': [*keys]})
+
+ for vif in dict.get('vif_s', {}).keys():
+ keys = D.get_child_nodes_diff(['vif-s', vif, 'vif-c'], expand_nodes=Diff.DELETE)['delete'].keys()
+ if keys:
+ dict.update({'vif_s': { vif : {'vif_c_remove': [*keys]}}})
+
+ return dict
+
def get_interface_dict(config, base, ifname):
"""
Common utility function to retrieve and mandgle the interfaces available
@@ -177,7 +204,6 @@ def get_interface_dict(config, base, ifname):
Will return a dictionary with the necessary interface configuration
"""
from vyos.xml import defaults
- from vyos.ifconfig_vlan import get_removed_vlans
# retrieve interface default values
default_values = defaults(base)
diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py
index 0e4ecda53..442cb0db8 100644
--- a/python/vyos/ifconfig_vlan.py
+++ b/python/vyos/ifconfig_vlan.py
@@ -16,33 +16,6 @@
from netifaces import interfaces
from vyos import ConfigError
-def get_removed_vlans(conf, dict):
- """
- Common function to parse a dictionary retrieved via get_config_dict() and
- determine any added/removed VLAN interfaces - be it 802.1q or Q-in-Q.
- """
- from vyos.configdiff import get_config_diff, Diff
-
- # Check vif, vif-s/vif-c VLAN interfaces for removal
- D = get_config_diff(conf, key_mangling=('-', '_'))
- D.set_level(conf.get_level())
- # get_child_nodes() will return dict_keys(), mangle this into a list with PEP448
- keys = D.get_child_nodes_diff(['vif'], expand_nodes=Diff.DELETE)['delete'].keys()
- if keys:
- dict.update({'vif_remove': [*keys]})
-
- # get_child_nodes() will return dict_keys(), mangle this into a list with PEP448
- keys = D.get_child_nodes_diff(['vif-s'], expand_nodes=Diff.DELETE)['delete'].keys()
- if keys:
- dict.update({'vif_s_remove': [*keys]})
-
- for vif in dict.get('vif_s', {}).keys():
- keys = D.get_child_nodes_diff(['vif-s', vif, 'vif-c'], expand_nodes=Diff.DELETE)['delete'].keys()
- if keys:
- dict.update({'vif_s': { vif : {'vif_c_remove': [*keys]}}})
-
- return dict
-
def apply_all_vlans(intf, intfconfig):
"""
Function applies all VLANs to the passed interface.