Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Modifications to get_optics to survive from N/A output power value #136

Merged
merged 1 commit into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions napalm_ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,13 @@ def get_optics(self):
port_detail['physical_channels'] = {}
port_detail['physical_channels']['channel'] = []

# If interface is shutdown it returns "N/A" as output power.
# Converting that to -40.0 float
try:
float(output_power)
except ValueError:
output_power = -40.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why -40? Is that an insane value that clearly indicates it is not supported/available? I am not an optics person myself :P

In any case, I am fine with having such a value if it makes sense but we should make it clear here:

https://github.com/napalm-automation/napalm-base/blob/develop/napalm_base/base.py#L1332

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking about this. I'm wondering whether it is good to use 0.0 as default value for optical powers as it is (in some cases) completely valid value. So 0.0 doesn't indicate not supported(available) see Cisco 10GBASE SFP+ Modules datasheet table 2 for example. Cisco uses value of -40.0 at Rx side to indicate "no light". Nevermind, as technology evolves somebody will create more sensitive receivers and -40.0 will be again valid value. Should we default to -100 or something?

Even you are fine with such value I think we should have it consistent across platforms and all values of Rx, Tx, instant, max, min, avg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am fine with -100 as a sort of "infinite" value. Eventually we will move this to the classes in napalm-yang and those have support to leave empty values.

Before moving forward I'd like @mirceaulinic's opinion though but if he agrees we can probably create a few issues to (1) document the behavior in napalm-base and (2) update the rest of the drivers as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense to me.


# Defaulting avg, min, max values to 0.0 since device does not
# return these values
optic_states = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"TenGigabitEthernet1/0/1": {
"physical_channels": {
"channel": [{
"index": 0,
"state": {
"output_power": {
"max": 0.0,
"avg": 0.0,
"instant": -2.0,
"min": 0.0
},
"laser_bias_current": {
"max": 0.0,
"avg": 0.0,
"instant": 0.0,
"min": 0.0
},
"input_power": {
"max": 0.0,
"avg": 0.0,
"instant": -3.5,
"min": 0.0
}
}
}]
}
},
"TenGigabitEthernet2/0/1": {
"physical_channels": {
"channel": [{
"index": 0,
"state": {
"output_power": {
"max": 0.0,
"avg": 0.0,
"instant": -40.0,
"min": 0.0
},
"laser_bias_current": {
"max": 0.0,
"avg": 0.0,
"instant": 0.0,
"min": 0.0
},
"input_power": {
"max": 0.0,
"avg": 0.0,
"instant": -40.0,
"min": 0.0
}
}
}]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
TenGigabitEthernet1/0/1 is up, line protocol is up (connected)
Hardware is Ten Gigabit Ethernet, address is 0042.5a67.0e9b (bia 0042.5a67.0e9b)
Description: Uplink-to-DSW1
MTU 1500 bytes, BW 10000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive not set
Full-duplex, 10Gb/s, link type is auto, media type is SFP-10GBase-LRM
input flow-control is off, output flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:02, output 00:00:04, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 61000 bits/sec, 52 packets/sec
5 minute output rate 59000 bits/sec, 63 packets/sec
13525429 packets input, 1636789604 bytes, 0 no buffer
Received 2388654 broadcasts (578107 multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 578107 multicast, 0 pause input
0 input packets with dribble condition detected
7831375 packets output, 870124569 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
TenGigabitEthernet2/0/1 is up, line protocol is up (connected)
Hardware is Ten Gigabit Ethernet, address is 0042.5a8d.d91b (bia 0042.5a8d.d91b)
Description: Uplink-to-DSW2
MTU 1500 bytes, BW 10000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive not set
Full-duplex, 10Gb/s, link type is auto, media type is SFP-10GBase-LRM
input flow-control is off, output flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:29, output 00:00:01, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 187000 bits/sec, 135 packets/sec
5 minute output rate 181000 bits/sec, 113 packets/sec
21192627 packets input, 4732793131 bytes, 0 no buffer
Received 1625861 broadcasts (279957 multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 279957 multicast, 0 pause input
0 input packets with dribble condition detected
27963853 packets output, 3954071411 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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 Tx Power Rx Power
Port (Celsius) (Volts) (dBm) (dBm)
--------- ----------- ------- -------- --------
Te1/0/1 34.6 3.29 -2.0 -3.5
Te2/0/1 34.3 3.28 N/A -40.0