We call iproute2 commands a lot, and it supports JSON output, so it would be handy to be able to write just vyos.utils.process.ip_cmd("link list") or similar.
Description
Description
Details
Details
- Version
- -
- Is it a breaking change?
- Perfectly compatible
Related Objects
Related Objects
Event Timeline
Comment Actions
PR https://github.com/vyos/vyos-1x/pull/3737
>>> from vyos.utils.process import ip_cmd
>>>
>>> ip_cmd("link list")
[{'ifindex': 1, 'ifname': 'lo', 'flags': ['LOOPBACK', 'UP', 'LOWER_UP'], 'mtu': 65536, 'qdisc': 'noqueue', 'operstate': 'UNKNOWN', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'loopback', 'address': '00:00:00:00:00:00', 'broadcast': '00:00:00:00:00:00'}, {'ifindex': 2, 'ifname': 'eth0', 'flags': ['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'], 'mtu': 1500, 'qdisc': 'fq_codel', 'operstate': 'UP', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'ether', 'address': '52:54:00:e9:94:ab', 'broadcast': 'ff:ff:ff:ff:ff:ff', 'altnames': ['enp1s0']}, {'ifindex': 4, 'ifname': 'eth2', 'flags': ['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'], 'mtu': 1500, 'qdisc': 'fq_codel', 'operstate': 'UP', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'ether', 'address': '52:54:00:4a:f4:73', 'broadcast': 'ff:ff:ff:ff:ff:ff', 'altnames': ['enp3s0']}, {'ifindex': 5, 'ifname': 'eth3', 'flags': ['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'], 'mtu': 1500, 'qdisc': 'fq_codel', 'operstate': 'UP', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'ether', 'address': '52:54:00:71:73:ea', 'broadcast': 'ff:ff:ff:ff:ff:ff', 'altnames': ['enp9s0']}, {'ifindex': 6, 'link': None, 'ifname': 'pim6reg', 'flags': ['NOARP', 'UP', 'LOWER_UP'], 'mtu': 1452, 'qdisc': 'noqueue', 'operstate': 'UNKNOWN', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'pimreg'}, {'ifindex': 7, 'ifname': 'eth1', 'flags': ['BROADCAST', 'MULTICAST', 'UP', 'LOWER_UP'], 'mtu': 1500, 'qdisc': 'mq', 'operstate': 'UP', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'ether', 'address': '52:54:00:21:1e:3f', 'broadcast': 'ff:ff:ff:ff:ff:ff'}, {'ifindex': 10, 'ifname': 'dum0', 'flags': ['BROADCAST', 'NOARP', 'UP', 'LOWER_UP'], 'mtu': 1500, 'qdisc': 'noqueue', 'operstate': 'UNKNOWN', 'linkmode': 'DEFAULT', 'group': 'default', 'txqlen': 1000, 'link_type': 'ether', 'address': 'ae:cd:79:9b:32:35', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]
>>>