mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
add support for Link partner advertised link modes to ethtool parser
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20240907 v1.25.4
|
20240907 v1.25.4
|
||||||
|
- Enhance `ethtool` parser to support `link_partner_advertised_link_modes`
|
||||||
- Enhance `ifconfig` parser to support `utun` interfaces with assigned IPv4 addresses on macOS
|
- Enhance `ifconfig` parser to support `utun` interfaces with assigned IPv4 addresses on macOS
|
||||||
- Fix `mount` parser for cases where there are spaces in the filesystem name
|
- Fix `mount` parser for cases where there are spaces in the filesystem name
|
||||||
- Fix `ip-address` parser for Python 3.13 changes to IPv4 mapped IPv6 addresses
|
- Fix `ip-address` parser for Python 3.13 changes to IPv4 mapped IPv6 addresses
|
||||||
|
@ -172,7 +172,7 @@ import jc.utils
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = '`ethtool` command parser'
|
description = '`ethtool` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -248,10 +248,11 @@ def _parse_default(data: str) -> JSONDictType:
|
|||||||
supported_link_modes: List[str] = []
|
supported_link_modes: List[str] = []
|
||||||
supported_fec_modes: List[str] = []
|
supported_fec_modes: List[str] = []
|
||||||
advertised_link_modes: List[str] = []
|
advertised_link_modes: List[str] = []
|
||||||
|
link_partner_advertised_link_modes: List[str] = []
|
||||||
advertised_fec_modes: List[str] = []
|
advertised_fec_modes: List[str] = []
|
||||||
current_message_level: List[str] = []
|
current_message_level: List[str] = []
|
||||||
mode: str = '' # supported_link_modes, supported_fec_modes, advertised_link_modes,
|
mode: str = '' # supported_link_modes, supported_fec_modes, advertised_link_modes,
|
||||||
# advertised_fec_modes, current_message_level
|
# link_partner_advertised_link_modes, advertised_fec_modes, current_message_level
|
||||||
|
|
||||||
for line in filter(None, data.splitlines()):
|
for line in filter(None, data.splitlines()):
|
||||||
|
|
||||||
@ -294,6 +295,14 @@ def _parse_default(data: str) -> JSONDictType:
|
|||||||
mode = 'advertised_link_modes'
|
mode = 'advertised_link_modes'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if 'Link partner advertised link modes:' in line and 'Not reported' not in line:
|
||||||
|
_, val = line.split(':', maxsplit=1)
|
||||||
|
val = val.strip()
|
||||||
|
val_list = val.split()
|
||||||
|
link_partner_advertised_link_modes.extend(val_list)
|
||||||
|
mode = 'link_partner_advertised_link_modes'
|
||||||
|
continue
|
||||||
|
|
||||||
if 'Advertised FEC modes:' in line and 'Not reported' not in line:
|
if 'Advertised FEC modes:' in line and 'Not reported' not in line:
|
||||||
_, val = line.split(':', maxsplit=1)
|
_, val = line.split(':', maxsplit=1)
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
@ -326,6 +335,12 @@ def _parse_default(data: str) -> JSONDictType:
|
|||||||
advertised_link_modes.extend(val_list)
|
advertised_link_modes.extend(val_list)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if mode == 'link_partner_advertised_link_modes':
|
||||||
|
val = line.strip()
|
||||||
|
val_list = val.split()
|
||||||
|
link_partner_advertised_link_modes.extend(val_list)
|
||||||
|
continue
|
||||||
|
|
||||||
if mode == 'advertised_fec_modes':
|
if mode == 'advertised_fec_modes':
|
||||||
val = line.strip()
|
val = line.strip()
|
||||||
val_list = val.split()
|
val_list = val.split()
|
||||||
@ -346,6 +361,7 @@ def _parse_default(data: str) -> JSONDictType:
|
|||||||
(supported_link_modes, 'supported_link_modes'),
|
(supported_link_modes, 'supported_link_modes'),
|
||||||
(supported_fec_modes, 'supported_fec_modes'),
|
(supported_fec_modes, 'supported_fec_modes'),
|
||||||
(advertised_link_modes, 'advertised_link_modes'),
|
(advertised_link_modes, 'advertised_link_modes'),
|
||||||
|
(link_partner_advertised_link_modes, 'link_partner_advertised_link_modes'),
|
||||||
(advertised_fec_modes, 'advertised_fec_modes'),
|
(advertised_fec_modes, 'advertised_fec_modes'),
|
||||||
(current_message_level, 'current_message_level')
|
(current_message_level, 'current_message_level')
|
||||||
]
|
]
|
||||||
|
1
tests/fixtures/generic/ethtool--link-partner-advertised-link-modes.json
vendored
Normal file
1
tests/fixtures/generic/ethtool--link-partner-advertised-link-modes.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name":"eth0","supported_pause_frame_use":"Symmetric Receive-only","supports_auto_negotiation":true,"supported_fec_modes":[],"advertised_pause_frame_use":false,"advertised_auto_negotiation":true,"advertised_fec_modes":[],"link_partner_advertised_pause_frame_use":"Symmetric","link_partner_advertised_auto_negotiation":"Yes","link_partner_advertised_fec_modes":"Not reported","speed":"100Mb/s","duplex":"Full","port":"Twisted Pair","phyad":"0","transceiver":"external","auto_negotiation":false,"mdi_x":"Unknown","supports_wake_on":"d","wake_on":"d","link_detected":true,"supported_ports":["TP","MII"],"supported_link_modes":["10baseT/Half","10baseT/Full","100baseT/Half","100baseT/Full","1000baseT/Half","1000baseT/Full"],"advertised_link_modes":["10baseT/Half","10baseT/Full","100baseT/Half","100baseT/Full","1000baseT/Half","1000baseT/Full"],"link_partner_advertised_link_modes":["10baseT/Half","10baseT/Full","100baseT/Half","100baseT/Full"],"current_message_level":["0x00000007 (7)","drv probe link"],"speed_bps":100000000}
|
31
tests/fixtures/generic/ethtool--link-partner-advertised-link-modes.out
vendored
Normal file
31
tests/fixtures/generic/ethtool--link-partner-advertised-link-modes.out
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
Settings for eth0:
|
||||||
|
Supported ports: [ TP MII ]
|
||||||
|
Supported link modes: 10baseT/Half 10baseT/Full
|
||||||
|
100baseT/Half 100baseT/Full
|
||||||
|
1000baseT/Half 1000baseT/Full
|
||||||
|
Supported pause frame use: Symmetric Receive-only
|
||||||
|
Supports auto-negotiation: Yes
|
||||||
|
Supported FEC modes: Not reported
|
||||||
|
Advertised link modes: 10baseT/Half 10baseT/Full
|
||||||
|
100baseT/Half 100baseT/Full
|
||||||
|
1000baseT/Half 1000baseT/Full
|
||||||
|
Advertised pause frame use: Symmetric Receive-only
|
||||||
|
Advertised auto-negotiation: Yes
|
||||||
|
Advertised FEC modes: Not reported
|
||||||
|
Link partner advertised link modes: 10baseT/Half 10baseT/Full
|
||||||
|
100baseT/Half 100baseT/Full
|
||||||
|
Link partner advertised pause frame use: Symmetric
|
||||||
|
Link partner advertised auto-negotiation: Yes
|
||||||
|
Link partner advertised FEC modes: Not reported
|
||||||
|
Speed: 100Mb/s
|
||||||
|
Duplex: Full
|
||||||
|
Port: Twisted Pair
|
||||||
|
PHYAD: 0
|
||||||
|
Transceiver: external
|
||||||
|
Auto-negotiation: on
|
||||||
|
MDI-X: Unknown
|
||||||
|
Supports Wake-on: d
|
||||||
|
Wake-on: d
|
||||||
|
Current message level: 0x00000007 (7)
|
||||||
|
drv probe link
|
||||||
|
Link detected: yes
|
Reference in New Issue
Block a user