@@ -1618,6 +1618,9 @@ def get_optics(self):
16181618 vendor_rev_re = re .compile ("revision is (.*)$" , re .M )
16191619 serial_no_re = re .compile ("serial number is (.*)$" , re .M )
16201620 type_no_re = re .compile ("type is (.*)$" , re .M )
1621+ lanes_re = re .compile (
1622+ r"^Lane Number:\d+.*?(?=Lane Number:|\Z)" , re .M | re .DOTALL
1623+ )
16211624 rx_instant_re = re .compile (r"Rx Power[ ]+(?:(\S+?)[ ]+dBm|(N.A))" , re .M )
16221625 tx_instant_re = re .compile (r"Tx Power[ ]+(?:(\S+?)[ ]+dBm|(N.A))" , re .M )
16231626 current_instant_re = re .compile (r"Current[ ]+(?:(\S+?)[ ]+mA|(N.A))" , re .M )
@@ -1646,59 +1649,65 @@ def get_optics(self):
16461649 "connector_type" : self .connector_type_map .get (type_s , "Unknown" ),
16471650 }
16481651 if "DOM is not supported" not in port_ts :
1649- res = rx_instant_re .search (port_ts )
1650- input_power = res .group (1 ) or res .group (2 )
1651- res = tx_instant_re .search (port_ts )
1652- output_power = res .group (1 ) or res .group (2 )
1653- res = current_instant_re .search (port_ts )
1654- current = res .group (1 ) or res .group (2 )
1655-
1656- # If interface is shutdown it returns "N/A" as output power
1657- # or "N/A" as input power
1658- # Converting that to -100.0 float
1659- try :
1660- float (output_power )
1661- except ValueError :
1662- output_power = - 100.0
1663- try :
1664- float (input_power )
1665- except ValueError :
1666- input_power = - 100.0
1667- try :
1668- float (current )
1669- except ValueError :
1670- current = - 100.0
1671-
1672- # Defaulting avg, min, max values to -100.0 since device does not
1673- # return these values
1674- optic_states = {
1675- "index" : 0 ,
1676- "state" : {
1677- "input_power" : {
1678- "instant" : (
1679- float (input_power ) if "input_power" else - 100.0
1680- ),
1681- "avg" : - 100.0 ,
1682- "min" : - 100.0 ,
1683- "max" : - 100.0 ,
1684- },
1685- "output_power" : {
1686- "instant" : (
1687- float (output_power ) if "output_power" else - 100.0
1688- ),
1689- "avg" : - 100.0 ,
1690- "min" : - 100.0 ,
1691- "max" : - 100.0 ,
1692- },
1693- "laser_bias_current" : {
1694- "instant" : (float (current ) if "current" else - 100.0 ),
1695- "avg" : 0.0 ,
1696- "min" : 0.0 ,
1697- "max" : 0.0 ,
1652+ # Some transceivers have multiple lanes/channels
1653+ lanes = lanes_re .findall (port_ts )
1654+ if not lanes :
1655+ lanes = [port_ts ]
1656+
1657+ for index , lane in enumerate (lanes ):
1658+ res = rx_instant_re .search (lane )
1659+ input_power = res .group (1 ) or res .group (2 )
1660+ res = tx_instant_re .search (lane )
1661+ output_power = res .group (1 ) or res .group (2 )
1662+ res = current_instant_re .search (lane )
1663+ current = res .group (1 ) or res .group (2 )
1664+
1665+ # If interface is shutdown it returns "N/A" as output power
1666+ # or "N/A" as input power
1667+ # Converting that to -100.0 float
1668+ try :
1669+ float (output_power )
1670+ except ValueError :
1671+ output_power = - 100.0
1672+ try :
1673+ float (input_power )
1674+ except ValueError :
1675+ input_power = - 100.0
1676+ try :
1677+ float (current )
1678+ except ValueError :
1679+ current = - 100.0
1680+
1681+ # Defaulting avg, min, max values to -100.0 since device does not
1682+ # return these values
1683+ optic_states = {
1684+ "index" : index ,
1685+ "state" : {
1686+ "input_power" : {
1687+ "instant" : (
1688+ float (input_power ) if "input_power" else - 100.0
1689+ ),
1690+ "avg" : - 100.0 ,
1691+ "min" : - 100.0 ,
1692+ "max" : - 100.0 ,
1693+ },
1694+ "output_power" : {
1695+ "instant" : (
1696+ float (output_power ) if "output_power" else - 100.0
1697+ ),
1698+ "avg" : - 100.0 ,
1699+ "min" : - 100.0 ,
1700+ "max" : - 100.0 ,
1701+ },
1702+ "laser_bias_current" : {
1703+ "instant" : (float (current ) if "current" else - 100.0 ),
1704+ "avg" : 0.0 ,
1705+ "min" : 0.0 ,
1706+ "max" : 0.0 ,
1707+ },
16981708 },
1699- },
1700- }
1701- port_detail ["physical_channels" ]["channel" ].append (optic_states )
1709+ }
1710+ port_detail ["physical_channels" ]["channel" ].append (optic_states )
17021711
17031712 port_detail ["state" ] = state
17041713 optics_detail [port ] = port_detail
0 commit comments