Created
December 14, 2022 14:15
-
-
Save igalic/4e3c2d8fbb1a6aac7e16f1caf99b605e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [15]: print(ifs_txt) | |
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 | |
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> | |
inet6 ::1 prefixlen 128 | |
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 | |
inet 127.0.0.1 netmask 0xff000000 | |
groups: lo | |
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> | |
hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 | |
options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE> | |
ether 00:0d:3a:54:ad:1e | |
inet 10.0.0.35 netmask 0xffffff00 broadcast 10.0.0.255 | |
media: Ethernet 100GBase-CR4 <full-duplex,rxpause,txpause> | |
status: active | |
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> | |
mce0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> metric 0 mtu 1500 | |
options=8805bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,LRO,LINKSTATE> | |
ether 00:0d:3a:54:ad:1e | |
media: Ethernet 100GBase-CR4 <full-duplex,rxpause,txpause> | |
status: active | |
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> | |
In [16]: ifc = Ifconfig() | |
In [17]: ifc.parse(ifs_txt) | |
Out[17]: | |
defaultdict(list, | |
{'lo0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8c05957f0>], | |
'hn0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea11f0>], | |
'00:0d:3a:54:ad:1e': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea11f0>, | |
<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea1880>], | |
'mce0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea1880>]}) | |
In [18]: ifc.ifs_by_name() | |
Out[18]: | |
{'lo0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8c05957f0>], | |
'hn0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea11f0>], | |
'mce0': [<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea1880>]} | |
In [19]: ifc.ifs_by_mac() | |
Out[19]: | |
defaultdict(list, | |
{'00:0d:3a:54:ad:1e': [[<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea11f0>, | |
<cloudinit.distros.parsers.ifconfig.Ifstate at 0x8bcea1880>]]}) | |
In [20]: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment