diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 867f8a566..a98526e11 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -786,12 +786,17 @@ def get_optics(self): port_detail = {"physical_channels": {"channel": []}} - # If interface is shutdown it returns "N/A" as output power. + # If interface is shutdown it returns "N/A" as output power + # or "N/A" as input power # Converting that to -100.0 float try: float(output_power) except ValueError: output_power = -100.0 + try: + float(input_power) + except ValueError: + input_power = -100.0 # Defaulting avg, min, max values to -100.0 since device does not # return these values diff --git a/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/expected_result.json b/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/expected_result.json new file mode 100644 index 000000000..701dfa104 --- /dev/null +++ b/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/expected_result.json @@ -0,0 +1,669 @@ +{ + "TenGigabitEthernet3/2": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 38.1, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/6": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -4.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 10.7, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/12": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -5.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 10.6, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/17": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -5.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 17.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/31": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -6.2, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 15.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/45": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -100.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 0.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "GigabitEthernet5/47": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -6.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 12.2, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/2": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/10": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.3, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 5.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/12": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.8, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 42.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/14": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 39.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/16": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.7, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 39.4, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/17": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -3.3, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 5.6, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/19": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.6, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.1, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/20": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 6.7, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/21": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.4, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/22": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.4, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 6.3, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/23": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.7, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.0, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/24": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.2, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.4, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/25": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.2, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 5.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/27": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -2.5, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 7.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "TenGigabitEthernet7/29": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": -1.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 8.2, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + }, + "FortyGigabitEthernet7/33": { + "physical_channels": { + "channel": [ + { + "index": 0, + "state": { + "input_power": { + "instant": 0.9, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "output_power": { + "instant": 36.6, + "avg": -100.0, + "min": -100.0, + "max": -100.0 + }, + "laser_bias_current": { + "instant": 0.0, + "avg": 0.0, + "min": 0.0, + "max": 0.0 + } + } + } + ] + } + } +} diff --git a/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/show_interfaces_transceiver.txt b/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/show_interfaces_transceiver.txt new file mode 100644 index 000000000..468c661ab --- /dev/null +++ b/test/ios/mocked_data/test_get_optics/interface_shutdown_v2/show_interfaces_transceiver.txt @@ -0,0 +1,34 @@ +Alarms applicable when thresholds or values are not N/A. +If device is externally calibrated, only calibrated values are printed. +++ : high alarm, + : high warning, - : low warning, -- : low alarm. +NA or N/A: not applicable, Tx: transmit, Rx: receive. +mA: milliamperes, dBm: decibels (milliwatts). + + Optical Optical + Temperature Voltage Current Tx Power Rx Power +Port (Celsius) (Volts) (mA) (dBm) (dBm) +---------- ----------- ------- -------- -------- -------- +Te3/2 26.5 3.30 38.1 -1.9 -26.8 -- +Gi5/6 37.4 3.37 10.7 -4.9 -35.2 - +Gi5/12 40.0 3.35 10.6 -5.0 -4.6 +Gi5/17 31.5 3.31 17.0 -5.5 -8.6 +Gi5/31 43.0 3.20 15.5 -6.2 -9.2 +Gi5/45 23.8 3.30 0.0 N/A N/A -- +Gi5/47 34.2 3.30 12.2 -6.0 -40.0 +Te7/2 33.2 3.28 8.0 -2.0 -3.5 +Te7/10 35.1 3.28 5.9 -2.3 -3.8 +Te7/12 38.8 3.27 42.0 -1.8 -1.9 +Te7/14 38.2 3.30 39.5 -1.9 -4.8 +Te7/16 34.0 3.31 39.4 -1.7 -8.0 +Te7/17 34.8 3.15 5.6 -3.3 -4.8 +Te7/19 36.5 3.29 8.1 -2.6 -3.7 +Te7/20 34.4 3.30 6.7 -2.5 -3.0 +Te7/21 28.7 3.23 8.4 -2.5 -2.0 +Te7/22 34.7 3.29 6.3 -2.4 -3.0 +Te7/23 37.2 3.30 8.0 -1.7 -2.8 +Te7/24 31.9 3.24 8.4 -2.2 -2.6 +Te7/25 26.7 3.28 5.5 -2.2 -3.8 +Te7/27 30.1 3.30 7.9 -2.5 -2.7 +Te7/29 27.5 3.22 8.2 -1.9 -2.1 +Fo7/33 34.1 3.23 36.6 0.9 -2.8 +