diff options
| author | Roman Khramshin <HollyGurza@users.noreply.github.com> | 2024-11-21 13:41:10 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-21 09:41:10 +0200 |
| commit | b51cf400b42d7b2d05237169a813d1e952213558 (patch) | |
| tree | 12fe95038495b36d7d008400ae0b039430b051e4 /python/vyos/ifconfig/interface.py | |
| parent | 1a291b44716ae268916a95971016fb0cf9584ba0 (diff) | |
| download | veeos-1x-b51cf400b42d7b2d05237169a813d1e952213558.tar.gz veeos-1x-b51cf400b42d7b2d05237169a813d1e952213558.zip | |
T6796: QoS: match filter by interface(iif) (#4188)
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
| -rw-r--r-- | python/vyos/ifconfig/interface.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 002d3da9e..cd562e1fe 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -98,6 +98,10 @@ class Interface(Control): 'shellcmd': 'ip -json -detail link list dev {ifname}', 'format': lambda j: jmespath.search('[*].ifalias | [0]', json.loads(j)) or '', }, + 'ifindex': { + 'shellcmd': 'ip -json -detail link list dev {ifname}', + 'format': lambda j: jmespath.search('[*].ifindex | [0]', json.loads(j)) or '', + }, 'mac': { 'shellcmd': 'ip -json -detail link list dev {ifname}', 'format': lambda j: jmespath.search('[*].address | [0]', json.loads(j)), @@ -428,6 +432,17 @@ class Interface(Control): nft_command = f'add element inet vrf_zones ct_iface_map {{ "{self.ifname}" : {vrf_table_id} }}' self._nft_check_and_run(nft_command) + def get_ifindex(self): + """ + Get interface index by name + + Example: + >>> from vyos.ifconfig import Interface + >>> Interface('eth0').get_ifindex() + '2' + """ + return int(self.get_interface('ifindex')) + def get_min_mtu(self): """ Get hardware minimum supported MTU |
