diff options
author | Christian Breunig <christian@breunig.cc> | 2023-08-06 19:29:50 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-08-06 20:25:01 +0200 |
commit | d1c4294534dd04f075f89f1bb60736d56fc6c22a (patch) | |
tree | ac57287abb0842f5fa00dfa753b17b69e7df1de1 /python/vyos/configdict.py | |
parent | 0d4a19b42d0f0c70cb3ec2119b3d8dbb67efdc75 (diff) | |
download | vyos-1x-d1c4294534dd04f075f89f1bb60736d56fc6c22a.tar.gz vyos-1x-d1c4294534dd04f075f89f1bb60736d56fc6c22a.zip |
T5195: move helpers from vyos.validate to vyos.utils package
Diffstat (limited to 'python/vyos/configdict.py')
-rw-r--r-- | python/vyos/configdict.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 38f4475d4..2a47e88f9 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -245,6 +245,48 @@ def is_mirror_intf(conf, interface, direction=None): return ret_val +def has_address_configured(conf, intf): + """ + Checks if interface has an address configured. + Checks the following config nodes: + 'address', 'ipv6 address eui64', 'ipv6 address autoconf' + + Returns True if interface has address configured, False if it doesn't. + """ + from vyos.ifconfig import Section + ret = False + + old_level = conf.get_level() + conf.set_level([]) + + intfpath = 'interfaces ' + Section.get_config_path(intf) + if ( conf.exists(f'{intfpath} address') or + conf.exists(f'{intfpath} ipv6 address autoconf') or + conf.exists(f'{intfpath} ipv6 address eui64') ): + ret = True + + conf.set_level(old_level) + return ret + +def has_vrf_configured(conf, intf): + """ + Checks if interface has a VRF configured. + + Returns True if interface has VRF configured, False if it doesn't. + """ + from vyos.ifconfig import Section + ret = False + + old_level = conf.get_level() + conf.set_level([]) + + tmp = ['interfaces', Section.get_config_path(intf), 'vrf'] + if conf.exists(tmp): + ret = True + + conf.set_level(old_level) + return ret + def has_vlan_subinterface_configured(conf, intf): """ Checks if interface has an VLAN subinterface configured. |