napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.23k stars 549 forks source link

Get_optics() for EOS update to add 4 channel support #1581

Open susanhooks opened 2 years ago

susanhooks commented 2 years ago

Description of Issue/Question

Note: Please check https://guides.github.com/features/mastering-markdown/ to see how to properly format your request.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

napalm==3.3.1

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

(any)
 'vendor': 'Arista',
'os_version': '4.24.3M-19566922.4243M',

Steps to Reproduce the Issue

run get_optics() method on Arista platform

Error Traceback

N/A - this is to open an issue about modifying the get_optics() method, or creating a new method to add fuller support for optics output. Currently the command run against pyeAPI is show interfaces transceiver . The output returns information on only the first channel. It would be useful to us to have information on all 4 of the optical channels. The command show interfaces transceiver dom provides more verbose feedback and support for all channels. Please see sample json below and let me know if this is something that would be accepted as an addition or modification to the EOS methods.

{"interfaces": {"Ethernet49/1": {"displayName": "Ethernet49/1",
    "mediaType": "100GBASE-CWDM4",
    "parameters": {"aggrRxPwr": {"channels": {"-": 6.305702433206449},
                                 "unit": "dBm"},
                   "aggrTxPwr": {"channels": {"-": 5.345337560051156},
                                 "unit": "dBm"},
                   "rxPower": {"channels": {"1": 0.5808422475092492,
                                            "2": -0.9566320779750512,
                                            "3": 1.107243543809048,
                                            "4": 0.15192041762834307},
                               "unit": "dBm"},
                   "temperature": {"channels": {"-": 43.85546875},
                                   "unit": "C"},
                   "txBias": {"channels": {"1": 34.256,
                                           "2": 34.256,
                                           "3": 34.256,
                                           "4": 34.256},
                              "unit": "mA"},
                   "txPower": {"channels": {"1": -0.5645602284654601,
                                            "2": -0.9663866374468135,
                                            "3": -0.23604163388120014,
                                            "4": -0.9783387072894847},
                               "unit": "dBm"},
                   "voltage": {"channels": {"-": 3.3251},
                               "unit": "V"}},
    "updateTime": 1646940176.398959,
    "vendorSn": "REDACTED"}}}
bewing commented 2 years ago

Per Arista TOI (registration required) this command was added in 4.21.5F. I do not know if it immediately had JSON support in the same release

https://www.arista.com/en/support/toi/eos-4-21-5f/14185-show-interfaces-transceiver-dom-thresholds

bewing commented 2 years ago

The current behavior appears to assign subsequent channels to sub-numbered interfaces:

switch#show int et53/1
Ethernet53/1 is up, line protocol is up (connected)
  Hardware is Ethernet, address is 985d.82d2.36c7
  Description: 100G
  Internet address is 192.0.2.1/31
  Broadcast address is 255.255.255.255
  IP MTU 1500 bytes (default) , BW 100000000 kbit
  Full-duplex, 100Gb/s, auto negotiation: off, uni-link: disabled

switch#show int et53/1 trans
If device is externally calibrated, only calibrated values are printed.
N/A: not applicable, Tx: transmit, Rx: receive.
mA: milliamperes, dBm: decibels (milliwatts).
                               Bias      Optical   Optical
          Temp       Voltage   Current   Tx Power  Rx Power
Port      (Celsius)  (Volts)   (mA)      (dBm)     (dBm)     Last Update
-----     ---------  --------  --------  --------  --------  -------------------
Et53/1     58.09      3.33      45.24    2.38      -1.60     0:00:03 ago
switch#show int et53/4 trans
If device is externally calibrated, only calibrated values are printed.
N/A: not applicable, Tx: transmit, Rx: receive.
mA: milliamperes, dBm: decibels (milliwatts).
                               Bias      Optical   Optical
          Temp       Voltage   Current   Tx Power  Rx Power
Port      (Celsius)  (Volts)   (mA)      (dBm)     (dBm)     Last Update
-----     ---------  --------  --------  --------  --------  -------------------
Et53/4     58.09      3.33      43.08    1.85      -1.57     0:00:01 ago

switch#show int et53/1 transceiver dom
Ch: Channel, N/A: not applicable, TX: transmit, RX: receive
mA: milliamperes, dBm: decibels (milliwatts), C: Celsius, V: Volts

Port 53
Last update: 0:00:03 ago
                                             Value
                                        ----------------
   Temperature                              58.09 C
   Voltage                                   3.33 V
   Aggregate TX Power                        8.23 dBm
   Aggregate RX Power                        4.15 dBm
Ethernet53/1
   TX bias current
      Channel        1                      45.24 mA
      Channel        2                      45.24 mA
      Channel        3                      45.24 mA
      Channel        4                      43.08 mA
   Optical TX power
      Channel        1                       2.38 dBm
      Channel        2                       2.40 dBm
      Channel        3                       2.19 dBm
      Channel        4                       1.85 dBm
   Optical RX power
      Channel        1                      -1.59 dBm
      Channel        2                      -1.70 dBm
      Channel        3                      -2.72 dBm
      Channel        4                      -1.57 dBm

Note that the TX bias for 53/1 and 53/4 in the original command correctly reflect the channels in the dom commands.

Changing this to report multiple channels on the base interface may be a breaking change.

susanhooks commented 2 years ago

I think this would not be a breaking change, in that the output is the same, but with more channels. Since the command was extended, we could check for cli_version and add dom to the end of the show interfaces transceiver based on that.

cli_version is already available in the device object. https://github.com/napalm-automation/napalm/blob/develop/napalm/eos/eos.py#L169

susanhooks commented 2 years ago

Would it be ok for me to submit this change for testing, or should I go down another path such as adding this as a new method?