napalm-automation / napalm-junos

Apache License 2.0
22 stars 42 forks source link

support for 40G/100G optical information #208

Closed ckishimo closed 6 years ago

ckishimo commented 6 years ago

Just modified the get_optics() method to include the optical information from 40G/100G optics using four different lanes. Not sure that is the best way of doing it but as I wanted to keep the main loop structure I had to re-format the input data a bit. Example:

juniper> show interfaces diagnostics optics et-0/0/50 
Physical interface: et-0/0/50
    Module temperature                        :  34 degrees C / 94 degrees F
    Module voltage                            :  3.2730 V
    Module temperature high alarm             :  Off
    Module temperature low alarm              :  Off
    Module temperature high warning           :  Off
    Module temperature low warning            :  Off
    Module voltage high alarm                 :  Off
    Module voltage low alarm                  :  Off
    Module voltage high warning               :  Off
    Module voltage low warning                :  Off
    Module temperature high alarm threshold   :  75 degrees C / 167 degrees F
    Module temperature low alarm threshold    :  -5 degrees C / 23 degrees F
    Module temperature high warning threshold :  70 degrees C / 158 degrees F
    Module temperature low warning threshold  :  0 degrees C / 32 degrees F
    Module voltage high alarm threshold       :  3.6300 V
    Module voltage low alarm threshold        :  2.9700 V
    Module voltage high warning threshold     :  3.4640 V
    Module voltage low warning threshold      :  3.1340 V
    Laser bias current high alarm threshold   :  9.999 mA
    Laser bias current low alarm threshold    :  0.499 mA
    Laser bias current high warning threshold :  9.499 mA
    Laser bias current low warning threshold  :  0.999 mA
    Laser output power high alarm threshold   :  Not supported
    Laser output power low alarm threshold    :  Not supported
    Laser output power high warning threshold :  Not supported
    Laser output power low warning threshold  :  Not supported
    Laser rx power high alarm threshold       :  2.1878 mW / 3.40 dBm
    Laser rx power low alarm threshold        :  0.0446 mW / -13.51 dBm
    Laser rx power high warning threshold     :  1.7378 mW / 2.40 dBm
    Laser rx power low warning threshold      :  0.1122 mW / -9.50 dBm
  Lane 0
    Laser bias current                        :  6.677 mA
    Laser output power                        :  0.763 mW / -1.17 dBm
    Laser receiver power                      :  0.759 mW / -1.20 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 1
    Laser bias current                        :  6.705 mA
    Laser output power                        :  0.834 mW / -0.79 dBm
    Laser receiver power                      :  0.719 mW / -1.43 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 2
    Laser bias current                        :  6.921 mA
    Laser output power                        :  0.823 mW / -0.84 dBm
    Laser receiver power                      :  0.744 mW / -1.29 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 3
    Laser bias current                        :  6.972 mA
    Laser output power                        :  0.814 mW / -0.89 dBm
    Laser receiver power                      :  0.752 mW / -1.23 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off

The output from the get_optics() method:

{
    "et-0/0/50": {
        "physical_channels": {
            "channel": [
                {
                    "index": 0, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.22, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.679, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -1.14, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 1, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.46, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.659, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.81, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 2, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.29, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.973, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.85, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 3, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.22, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.934, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.9, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }
            ]
        }
   },
}

The output before was:

{
    "et-0/0/50": {
        "physical_channels": {
            "channel": [
                {
                    "index": 0, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }
            ]
        }
    }, 
}

Note I had to temporary tweak the code to overcome the error #146 'ValueError: could not convert string to float: - Inf' Let me know. Thanks

coveralls commented 6 years ago

Coverage Status

Changes Unknown when pulling c6cf072c7ab2120aa5927bcb226aec9ed3a9a648 on ckishimo:develop into on napalm-automation:develop.

coveralls commented 6 years ago

Coverage Status

Changes Unknown when pulling 214d1c66229da833328c836e29c91c5c6739c730 on ckishimo:develop into on napalm-automation:develop.

coveralls commented 6 years ago

Coverage Status

Changes Unknown when pulling 708bed78bc84dcb826f5d1f2115edc09a108a167 on ckishimo:develop into on napalm-automation:develop.

coveralls commented 6 years ago

Coverage Status

Changes Unknown when pulling 4875a4868caa397ca39dc41818db8163735fe56a on ckishimo:develop into on napalm-automation:develop.

coveralls commented 6 years ago

Coverage Status

Changes Unknown when pulling 4875a4868caa397ca39dc41818db8163735fe56a on ckishimo:develop into on napalm-automation:develop.