diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2026-07-02 17:23:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-02 17:23:21 +0300 |
| commit | bf64dbd6a2fc006e29814cda59cfac6506978b44 (patch) | |
| tree | d4655b06e0c9976a5ecdeae87205e944e098c7b9 /python | |
| parent | 063e007a5a8eac3bb9ad101206dc94734eeaa595 (diff) | |
| parent | 0d3ac22b95cef90e7c54ef823c00bb59b935c158 (diff) | |
| download | vyos-1x-bf64dbd6a2fc006e29814cda59cfac6506978b44.tar.gz vyos-1x-bf64dbd6a2fc006e29814cda59cfac6506978b44.zip | |
Merge pull request #5167 from davi2367/zbf-vrf
firewall: T8761: Reintroduce VRF-interface names in generated config
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/configdict.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index e721942ca..1a3165a8f 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -19,6 +19,7 @@ A library for retrieving value dicts from VyOS configs in a declarative fashion. import os import json +from vyos.config import Config from vyos.utils.dict import dict_search from vyos.utils.process import cmd @@ -300,6 +301,34 @@ def has_vrf_configured(conf, intf): conf.set_level(old_level) return ret +def is_vrf_changed(conf : Config, intf) -> bool: + """ + Checks if interface has a VRF changed. + + Returns True if interface has VRF changed, False if it doesn't. + """ + from vyos.ifconfig import Section + + # set default path for this interface + intfpath = ['interfaces', Section.section(intf), intf] + + # Check top-level interface + if is_node_changed(conf, intfpath + ['vrf']): + return True + + # check sub interfaces + for vif in conf.list_nodes(intfpath + ['vif']): + if is_node_changed(conf, intfpath + ['vif', vif, 'vrf']): + return True + for vif_s in conf.list_nodes(intfpath + ['vif-s']): + if is_node_changed(conf, intfpath + ['vif-s', vif_s, 'vrf']): + return True + for vif_c in conf.list_nodes(intfpath + ['vif-s', vif_s, 'vif-c']): + if is_node_changed(conf, intfpath + ['vif-s', vif_s, 'vif-c', vif_c, 'vrf']): + return True + + return False + def has_vlan_subinterface_configured(conf, intf): """ Checks if interface has an VLAN subinterface configured. |
