@@ -77,11 +77,10 @@ def search_ont(sn: str, host: str) -> tuple[dict, str | None] | None:
7777 catv_results .append (catv )
7878
7979 eth_results = []
80- for port_num in range (1 , (ont_info ['_eth_ports' ] or 2 ) + 1 ):
81- sleep (0.07 )
82- channel .send (bytes (f"display ont port attribute { ont_info ['interface' ]['port' ]} { ont_info ['ont_id' ]} eth { port_num } \n " , 'utf-8' ))
83- eth = parse_port_status (read_output (channel ))
84- eth_results .append (eth )
80+
81+ channel .send (bytes (f"display ont port state { ont_info ['interface' ]['port' ]} { ont_info ['ont_id' ]} eth-port all\n " , 'utf-8' ))
82+ eth = parse_eth_ports_status (read_output (channel ))
83+ eth_results .append (eth )
8584
8685 ont_info ['catv' ] = catv_results
8786 ont_info ['eth' ] = eth_results
@@ -353,6 +352,10 @@ def parse_port_status(raw: str) -> bool:
353352 _ , tables = _parse_output (raw )
354353 return tables [0 ][0 ].get ('Port-switch' ) or tables [0 ][0 ].get ('switch' ) or tables [0 ][0 ].get ('Port' ) or False
355354
355+ def parse_eth_ports_status (raw : str ) -> list [dict ]:
356+ """Parse ONT eth ports status"""
357+ _ , tables = _parse_output (raw )
358+ return [{'id' : table .get ('ONT-port-id' ), 'status' : table .get ('LinkState' ) or False , 'speed' : table .get ('Speed-(Mbps)' )} for table in tables [0 ]]
356359
357360def parse_onts_info (output : str ) -> tuple [int , int , list [dict ]] | tuple [dict , None , None ]:
358361 out = [line .strip () for line in (output .replace (PAGINATION_WITH_SPACES , "" ).split (DIVIDER ))]
0 commit comments