napalm-automation / napalm

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

get_optics fails on some JUNOS versions (12.3R2, 11.4) #491

Closed jamesboswell closed 6 years ago

jamesboswell commented 7 years ago

Description of Issue/Question

get_optics fails on some JUNOS versions, including 12.3 and 11.4 (admittedly < 12.1 supported).
This is due to a simple space inserted in the output for Infinite light levels.

A simple change to L61 in constants.py to add a space fixes this issue in my environment. However, I realize this may not be universally true.

_Perhaps this should be a regex instead of list membership tests in junos.py?_

Local workaround

diff --git a/napalm_base/constants.py b/napalm_base/constants.py
index bcfbff9..cb328dc 100644
--- a/napalm_base/constants.py
+++ b/napalm_base/constants.py
@@ -58,7 +58,7 @@ TRACEROUTE_NULL_HOST_NAME = '*'
 TRACEROUTE_NULL_IP_ADDRESS = '*'
 TRACEROUTE_VRF = ''

-OPTICS_NULL_LEVEL = '-Inf'
+OPTICS_NULL_LEVEL = '- Inf'

 PING_SOURCE = ''
 PING_TTL = 255

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

[X] Yes [ ] No

napalm version

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

napalm==1.2.0
napalm-base==0.25.0
napalm-eos==0.6.1
napalm-fortios==0.4.0
napalm-ios==0.8.0
napalm-iosxr==0.5.4
napalm-junos==0.12.0
napalm-nxos==0.7.0
napalm-panos==0.4.0
napalm-pluribus==0.5.1
napalm-ros==0.2.2
napalm-vyos==0.1.3

Network device software version

(Paste verbatim output from show version (or equivalent on your platform) between quotes below)

show version
Hostname: <REMOVED>
Model: mx960
JUNOS Base OS boot [12.3R2.5]
JUNOS Base OS Software Suite [12.3R2.5]
JUNOS Kernel Software Suite [12.3R2.5]
JUNOS Crypto Software Suite [12.3R2.5]
JUNOS Packet Forwarding Engine Support (M/T/EX Common) [12.3R2.5]
JUNOS Packet Forwarding Engine Support (MX Common) [12.3R2.5]
JUNOS Online Documentation [12.3R2.5]
JUNOS Services AACL Container package [12.3R2.5]
JUNOS Services Application Level Gateways [12.3R2.5]
JUNOS AppId Services [12.3R2.5]
JUNOS Border Gateway Function package [12.3R2.5]
JUNOS Services Captive Portal and Content Delivery Container package [12.3R2.5]
JUNOS Services HTTP Content Management package [12.3R2.5]
JUNOS IDP Services [12.3R2.5]
JUNOS Services LL-PDF Container package [12.3R2.5]
JUNOS Services NAT [12.3R2.5]
JUNOS Services PTSP Container package [12.3R2.5]
JUNOS Services RPM [12.3R2.5]
JUNOS Services Stateful Firewall [12.3R2.5]
JUNOS Voice Services Container package [12.3R2.5]
JUNOS Services Example Container package [12.3R2.5]
JUNOS Services Crypto [12.3R2.5]
JUNOS Services SSL [12.3R2.5]
JUNOS Services IPSec [12.3R2.5]
JUNOS Runtime Software Suite [12.3R2.5]
JUNOS platform Software Suite [12.3R2.5]
JUNOS Routing Software Suite [12.3R2.5]

Steps to Reproduce the Issue

Call get_optics on a JUNOS MX960 running 12.3R2.5

Juniper CLI OUTPUT

show interfaces diagnostics optics et-0/1/0
Physical interface: et-0/1/0
    Module temperature                        :  42 degrees C / 107 degrees F
    Module voltage                            :  3.2920 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 not ready alarm                    :  Off
    Module low power alarm                    :  Off
    Module initialization incomplete alarm    :  Off
    Module fault alarm                        :  Off
    PLD Flash initialization fault alarm      :  Off
    Power supply fault alarm                  :  Off
    Checksum fault alarm                      :  Off
    Tx laser disabled alarm                   :  Off
    Tx loss of signal functionality alarm     :  Off
    Tx CDR loss of lock alarm                 :  Off
    Rx loss of signal alarm                   :  Off
    Rx CDR loss of lock alarm                 :  Off
    Module temperature high alarm threshold   :  74 degrees C / 165 degrees F
    Module temperature low alarm threshold    :  -4 degrees C / 25 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.6640 V
    Module voltage low alarm threshold        :  2.9340 V
    Module voltage high warning threshold     :  3.4640 V
    Module voltage low warning threshold      :  3.1340 V
    Laser bias current high alarm threshold   :  15.000 mA
    Laser bias current low alarm threshold    :  4.000 mA
    Laser bias current high warning threshold :  14.000 mA
    Laser bias current low warning threshold  :  5.000 mA
    Laser output power high alarm threshold   :  0.0000 mW / - Inf dBm
    Laser output power low alarm threshold    :  0.0000 mW / - Inf dBm
    Laser output power high warning threshold :  0.0000 mW / - Inf dBm
    Laser output power low warning threshold  :  0.0000 mW / - Inf dBm
    Laser rx power high alarm threshold       :  0.0000 mW / - Inf dBm
    Laser rx power low alarm threshold        :  0.0000 mW / - Inf dBm
    Laser rx power high warning threshold     :  0.0000 mW / - Inf dBm
    Laser rx power low warning threshold      :  0.0000 mW / - Inf dBm
    Laser temperature high alarm threshold    :  74 degrees C / 165 degrees F
    Laser temperature low alarm threshold     :  -4 degrees C / 25 degrees F
    Laser temperature high warning threshold  :  70 degrees C / 158 degrees F
    Laser temperature low warning threshold   :  0 degrees C / 32 degrees F

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "nuke.py", line 32, in <module>
    optics = device.get_optics()
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_junos/junos.py", line 1785, in get_optics
    [None, C.OPTICS_NULL_LEVEL]
ValueError: could not convert string to float: - Inf

Trace captured

Please, reproduce the issue with the cli tool in debug mode and paste the entire execution.

https://napalm.readthedocs.io/en/latest/cli.html

napalm --debug --user <REMOVED> --password <REMOVED> --vendor junos <REMOVED> call get_optics                                                                                                              1 ↵
2017-11-02 14:19:36,322 - napalm - DEBUG - Starting napalm's debugging tool
2017-11-02 14:19:36,322 - napalm - DEBUG - Gathering napalm packages
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-base==0.25.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-eos==0.6.1
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-fortios==0.4.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-ios==0.8.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-iosxr==0.5.4
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-junos==0.12.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-nxos==0.7.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-panos==0.4.0
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-pluribus==0.5.1
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-ros==0.2.2
2017-11-02 14:19:36,330 - napalm - DEBUG - napalm-vyos==0.1.3
2017-11-02 14:19:36,331 - napalm - DEBUG - napalm==1.2.0
2017-11-02 14:19:36,331 - napalm - DEBUG - get_network_driver - Calling with args: ('junos',), {}
2017-11-02 14:19:36,659 - napalm - DEBUG - get_network_driver - Successful
2017-11-02 14:19:36,659 - napalm - DEBUG - __init__ - Calling with args: (<class 'napalm_junos.junos.JunOSDriver'>, '<REMOVED>', '<REMOVED>'), {'password': u'*******', 'optional_args': {}, 'timeout': 60}
2017-11-02 14:19:36,660 - napalm - DEBUG - __init__ - Successful
2017-11-02 14:19:36,660 - napalm - DEBUG - pre_connection_tests - Calling with args: (<napalm_junos.junos.JunOSDriver object at 0x105e9cc10>,), {}
2017-11-02 14:19:36,660 - napalm - DEBUG - open - Calling with args: (<napalm_junos.junos.JunOSDriver object at 0x105e9cc10>,), {}
2017-11-02 14:19:38,979 - napalm - DEBUG - open - Successful
2017-11-02 14:19:38,979 - napalm - DEBUG - connection_tests - Calling with args: (<napalm_junos.junos.JunOSDriver object at 0x105e9cc10>,), {}
2017-11-02 14:19:38,979 - napalm - DEBUG - get_facts - Calling with args: (<napalm_junos.junos.JunOSDriver object at 0x105e9cc10>,), {}
2017-11-02 14:19:48,802 - napalm - DEBUG - Gathered facts:
{
    "os_version": "12.3R2.5",
    "uptime": 101732760,
    "interface_list": [
        "lc-0/0/0",
        "pfe-0/0/0",
        "pfh-0/0/0",
        "xe-0/0/0",
        "xe-0/0/1",
        "xe-0/0/2",
        "xe-0/0/3",
        "et-0/1/0",
        "lc-0/2/0",
        "pfe-0/2/0",
        "xe-0/2/0",
        "xe-0/2/1",
        "xe-0/2/2",
        "xe-0/2/3",
        "et-0/3/0",
        "lc-1/0/0",
        "pfe-1/0/0",
        "pfh-1/0/0",
        "xe-1/0/0",
        "xe-1/0/1",
        "xe-1/0/2",
        "xe-1/0/3",
        "et-1/1/0",
        "lc-1/2/0",
        "pfe-1/2/0",
        "xe-1/2/0",
        "xe-1/2/1",
        "xe-1/2/2",
        "xe-1/2/3",
        "et-1/3/0",
        "lc-2/0/0",
        "pfe-2/0/0",
        "pfh-2/0/0",
        "xe-2/0/0",
        "xe-2/0/1",
        "xe-2/0/2",
        "xe-2/0/3",
        "lc-2/1/0",
        "pfe-2/1/0",
        "xe-2/1/0",
        "xe-2/1/1",
        "xe-2/1/2",
        "xe-2/1/3",
        "lc-2/2/0",
        "pfe-2/2/0",
        "xe-2/2/0",
        "xe-2/2/1",
        "xe-2/2/2",
        "xe-2/2/3",
        "lc-2/3/0",
        "pfe-2/3/0",
        "xe-2/3/0",
        "xe-2/3/1",
        "xe-2/3/2",
        "xe-2/3/3",
        "lc-3/0/0",
        "pfe-3/0/0",
        "pfh-3/0/0",
        "xe-3/0/0",
        "xe-3/0/1",
        "xe-3/0/2",
        "xe-3/0/3",
        "lc-3/1/0",
        "pfe-3/1/0",
        "xe-3/1/0",
        "xe-3/1/1",
        "xe-3/1/2",
        "xe-3/1/3",
        "lc-3/2/0",
        "pfe-3/2/0",
        "xe-3/2/0",
        "xe-3/2/1",
        "xe-3/2/2",
        "xe-3/2/3",
        "lc-3/3/0",
        "pfe-3/3/0",
        "xe-3/3/0",
        "xe-3/3/1",
        "xe-3/3/2",
        "xe-3/3/3",
        "lc-4/0/0",
        "pfe-4/0/0",
        "pfh-4/0/0",
        "xe-4/0/0",
        "xe-4/0/1",
        "xe-4/0/2",
        "xe-4/0/3",
        "lc-4/1/0",
        "pfe-4/1/0",
        "xe-4/1/0",
        "xe-4/1/1",
        "xe-4/1/2",
        "xe-4/1/3",
        "lc-4/2/0",
        "pfe-4/2/0",
        "xe-4/2/0",
        "xe-4/2/1",
        "xe-4/2/2",
        "xe-4/2/3",
        "lc-4/3/0",
        "pfe-4/3/0",
        "xe-4/3/0",
        "xe-4/3/1",
        "xe-4/3/2",
        "xe-4/3/3",
        "lc-5/0/0",
        "pfe-5/0/0",
        "pfh-5/0/0",
        "xe-5/0/0",
        "xe-5/0/1",
        "xe-5/0/2",
        "xe-5/0/3",
        "lc-5/1/0",
        "pfe-5/1/0",
        "xe-5/1/0",
        "xe-5/1/1",
        "xe-5/1/2",
        "xe-5/1/3",
        "lc-5/2/0",
        "pfe-5/2/0",
        "xe-5/2/0",
        "xe-5/2/1",
        "xe-5/2/2",
        "xe-5/2/3",
        "lc-5/3/0",
        "pfe-5/3/0",
        "xe-5/3/0",
        "xe-5/3/1",
        "xe-5/3/2",
        "xe-5/3/3",
        "lc-6/0/0",
        "pfe-6/0/0",
        "pfh-6/0/0",
        "xe-6/0/0",
        "xe-6/0/1",
        "xe-6/0/2",
        "xe-6/0/3",
        "et-6/1/0",
        "lc-6/2/0",
        "pfe-6/2/0",
        "xe-6/2/0",
        "xe-6/2/1",
        "xe-6/2/2",
        "xe-6/2/3",
        "et-6/3/0",
        "lc-7/0/0",
        "pfe-7/0/0",
        "pfh-7/0/0",
        "xe-7/0/0",
        "xe-7/0/1",
        "xe-7/0/2",
        "xe-7/0/3",
        "lc-7/1/0",
        "pfe-7/1/0",
        "xe-7/1/0",
        "xe-7/1/1",
        "xe-7/1/2",
        "xe-7/1/3",
        "lc-7/2/0",
        "pfe-7/2/0",
        "xe-7/2/0",
        "xe-7/2/1",
        "xe-7/2/2",
        "xe-7/2/3",
        "lc-7/3/0",
        "pfe-7/3/0",
        "xe-7/3/0",
        "xe-7/3/1",
        "xe-7/3/2",
        "xe-7/3/3",
        "lc-8/0/0",
        "pfe-8/0/0",
        "pfh-8/0/0",
        "xe-8/0/0",
        "xe-8/0/1",
        "xe-8/0/2",
        "xe-8/0/3",
        "lc-8/1/0",
        "pfe-8/1/0",
        "xe-8/1/0",
        "xe-8/1/1",
        "xe-8/1/2",
        "xe-8/1/3",
        "lc-8/2/0",
        "pfe-8/2/0",
        "xe-8/2/0",
        "xe-8/2/1",
        "xe-8/2/2",
        "xe-8/2/3",
        "lc-8/3/0",
        "pfe-8/3/0",
        "xe-8/3/0",
        "xe-8/3/1",
        "xe-8/3/2",
        "xe-8/3/3",
        "lc-9/0/0",
        "pfe-9/0/0",
        "pfh-9/0/0",
        "xe-9/0/0",
        "xe-9/0/1",
        "xe-9/0/2",
        "xe-9/0/3",
        "lc-9/1/0",
        "pfe-9/1/0",
        "xe-9/1/0",
        "xe-9/1/1",
        "xe-9/1/2",
        "xe-9/1/3",
        "lc-9/2/0",
        "pfe-9/2/0",
        "xe-9/2/0",
        "xe-9/2/1",
        "xe-9/2/2",
        "xe-9/2/3",
        "lc-9/3/0",
        "pfe-9/3/0",
        "xe-9/3/0",
        "xe-9/3/1",
        "xe-9/3/2",
        "xe-9/3/3",
        "lc-10/0/0",
        "pfe-10/0/0",
        "pfh-10/0/0",
        "xe-10/0/0",
        "xe-10/0/1",
        "xe-10/0/2",
        "xe-10/0/3",
        "lc-10/1/0",
        "pfe-10/1/0",
        "xe-10/1/0",
        "xe-10/1/1",
        "xe-10/1/2",
        "xe-10/1/3",
        "lc-10/2/0",
        "pfe-10/2/0",
        "xe-10/2/0",
        "xe-10/2/1",
        "xe-10/2/2",
        "xe-10/2/3",
        "lc-10/3/0",
        "pfe-10/3/0",
        "xe-10/3/0",
        "xe-10/3/1",
        "xe-10/3/2",
        "xe-10/3/3",
        "lc-11/0/0",
        "pfe-11/0/0",
        "pfh-11/0/0",
        "xe-11/0/0",
        "xe-11/0/1",
        "xe-11/0/2",
        "xe-11/0/3",
        "et-11/1/0",
        "lc-11/2/0",
        "pfe-11/2/0",
        "xe-11/2/0",
        "xe-11/2/1",
        "xe-11/2/2",
        "xe-11/2/3",
        "et-11/3/0",
        ".local.",
        "ae0",
        "ae1",
        "ae2",
        "ae3",
        "ae4",
        "ae5",
        "ae6",
        "ae7",
        "ae8",
        "ae9",
        "ae10",
        "ae11",
        "ae12",
        "ae13",
        "ae14",
        "ae15",
        "ae16",
        "ae17",
        "ae18",
        "ae19",
        "ae20",
        "ae21",
        "ae22",
        "ae23",
        "ae24",
        "ae25",
        "ae26",
        "ae27",
        "ae28",
        "ae29",
        "ae30",
        "ae31",
        "ae32",
        "ae33",
        "ae34",
        "ae35",
        "ae36",
        "ae37",
        "ae38",
        "ae39",
        "ae40",
        "ae41",
        "ae42",
        "ae43",
        "ae44",
        "ae45",
        "ae46",
        "ae47",
        "ae48",
        "ae49",
        "ae50",
        "ae51",
        "ae52",
        "ae53",
        "ae54",
        "ae55",
        "ae56",
        "ae57",
        "ae58",
        "ae59",
        "ae60",
        "ae61",
        "ae62",
        "ae63",
        "as0",
        "as1",
        "as2",
        "as3",
        "as4",
        "as5",
        "as6",
        "as7",
        "as8",
        "as9",
        "as10",
        "as11",
        "as12",
        "as13",
        "as14",
        "as15",
        "cbp0",
        "demux0",
        "dsc",
        "em0",
        "em1",
        "fxp0",
        "gre",
        "ipip",
        "irb",
        "lo0",
        "lsi",
        "mtun",
        "pimd",
        "pime",
        "pip0",
        "pp0",
        "tap"
    ],
    "vendor": "Juniper",
    "serial_number": "JN11C2<REMOVED>",
    "model": "MX960",
    "hostname": "<REMOVED>",
    "fqdn": "<REMOVED>"
}
{
    "os_version": "12.3R2.5",
    "uptime": 101732760,
    "interface_list": [
        "lc-0/0/0",
        "pfe-0/0/0",
        "pfh-0/0/0",
        "xe-0/0/0",
        "xe-0/0/1",
        "xe-0/0/2",
        "xe-0/0/3",
        "et-0/1/0",
        "lc-0/2/0",
        "pfe-0/2/0",
        "xe-0/2/0",
        "xe-0/2/1",
        "xe-0/2/2",
        "xe-0/2/3",
        "et-0/3/0",
        "lc-1/0/0",
        "pfe-1/0/0",
        "pfh-1/0/0",
        "xe-1/0/0",
        "xe-1/0/1",
        "xe-1/0/2",
        "xe-1/0/3",
        "et-1/1/0",
        "lc-1/2/0",
        "pfe-1/2/0",
        "xe-1/2/0",
        "xe-1/2/1",
        "xe-1/2/2",
        "xe-1/2/3",
        "et-1/3/0",
        "lc-2/0/0",
        "pfe-2/0/0",
        "pfh-2/0/0",
        "xe-2/0/0",
        "xe-2/0/1",
        "xe-2/0/2",
        "xe-2/0/3",
        "lc-2/1/0",
        "pfe-2/1/0",
        "xe-2/1/0",
        "xe-2/1/1",
        "xe-2/1/2",
        "xe-2/1/3",
        "lc-2/2/0",
        "pfe-2/2/0",
        "xe-2/2/0",
        "xe-2/2/1",
        "xe-2/2/2",
        "xe-2/2/3",
        "lc-2/3/0",
        "pfe-2/3/0",
        "xe-2/3/0",
        "xe-2/3/1",
        "xe-2/3/2",
        "xe-2/3/3",
        "lc-3/0/0",
        "pfe-3/0/0",
        "pfh-3/0/0",
        "xe-3/0/0",
        "xe-3/0/1",
        "xe-3/0/2",
        "xe-3/0/3",
        "lc-3/1/0",
        "pfe-3/1/0",
        "xe-3/1/0",
        "xe-3/1/1",
        "xe-3/1/2",
        "xe-3/1/3",
        "lc-3/2/0",
        "pfe-3/2/0",
        "xe-3/2/0",
        "xe-3/2/1",
        "xe-3/2/2",
        "xe-3/2/3",
        "lc-3/3/0",
        "pfe-3/3/0",
        "xe-3/3/0",
        "xe-3/3/1",
        "xe-3/3/2",
        "xe-3/3/3",
        "lc-4/0/0",
        "pfe-4/0/0",
        "pfh-4/0/0",
        "xe-4/0/0",
        "xe-4/0/1",
        "xe-4/0/2",
        "xe-4/0/3",
        "lc-4/1/0",
        "pfe-4/1/0",
        "xe-4/1/0",
        "xe-4/1/1",
        "xe-4/1/2",
        "xe-4/1/3",
        "lc-4/2/0",
        "pfe-4/2/0",
        "xe-4/2/0",
        "xe-4/2/1",
        "xe-4/2/2",
        "xe-4/2/3",
        "lc-4/3/0",
        "pfe-4/3/0",
        "xe-4/3/0",
        "xe-4/3/1",
        "xe-4/3/2",
        "xe-4/3/3",
        "lc-5/0/0",
        "pfe-5/0/0",
        "pfh-5/0/0",
        "xe-5/0/0",
        "xe-5/0/1",
        "xe-5/0/2",
        "xe-5/0/3",
        "lc-5/1/0",
        "pfe-5/1/0",
        "xe-5/1/0",
        "xe-5/1/1",
        "xe-5/1/2",
        "xe-5/1/3",
        "lc-5/2/0",
        "pfe-5/2/0",
        "xe-5/2/0",
        "xe-5/2/1",
        "xe-5/2/2",
        "xe-5/2/3",
        "lc-5/3/0",
        "pfe-5/3/0",
        "xe-5/3/0",
        "xe-5/3/1",
        "xe-5/3/2",
        "xe-5/3/3",
        "lc-6/0/0",
        "pfe-6/0/0",
        "pfh-6/0/0",
        "xe-6/0/0",
        "xe-6/0/1",
        "xe-6/0/2",
        "xe-6/0/3",
        "et-6/1/0",
        "lc-6/2/0",
        "pfe-6/2/0",
        "xe-6/2/0",
        "xe-6/2/1",
        "xe-6/2/2",
        "xe-6/2/3",
        "et-6/3/0",
        "lc-7/0/0",
        "pfe-7/0/0",
        "pfh-7/0/0",
        "xe-7/0/0",
        "xe-7/0/1",
        "xe-7/0/2",
        "xe-7/0/3",
        "lc-7/1/0",
        "pfe-7/1/0",
        "xe-7/1/0",
        "xe-7/1/1",
        "xe-7/1/2",
        "xe-7/1/3",
        "lc-7/2/0",
        "pfe-7/2/0",
        "xe-7/2/0",
        "xe-7/2/1",
        "xe-7/2/2",
        "xe-7/2/3",
        "lc-7/3/0",
        "pfe-7/3/0",
        "xe-7/3/0",
        "xe-7/3/1",
        "xe-7/3/2",
        "xe-7/3/3",
        "lc-8/0/0",
        "pfe-8/0/0",
        "pfh-8/0/0",
        "xe-8/0/0",
        "xe-8/0/1",
        "xe-8/0/2",
        "xe-8/0/3",
        "lc-8/1/0",
        "pfe-8/1/0",
        "xe-8/1/0",
        "xe-8/1/1",
        "xe-8/1/2",
        "xe-8/1/3",
        "lc-8/2/0",
        "pfe-8/2/0",
        "xe-8/2/0",
        "xe-8/2/1",
        "xe-8/2/2",
        "xe-8/2/3",
        "lc-8/3/0",
        "pfe-8/3/0",
        "xe-8/3/0",
        "xe-8/3/1",
        "xe-8/3/2",
        "xe-8/3/3",
        "lc-9/0/0",
        "pfe-9/0/0",
        "pfh-9/0/0",
        "xe-9/0/0",
        "xe-9/0/1",
        "xe-9/0/2",
        "xe-9/0/3",
        "lc-9/1/0",
        "pfe-9/1/0",
        "xe-9/1/0",
        "xe-9/1/1",
        "xe-9/1/2",
        "xe-9/1/3",
        "lc-9/2/0",
        "pfe-9/2/0",
        "xe-9/2/0",
        "xe-9/2/1",
        "xe-9/2/2",
        "xe-9/2/3",
        "lc-9/3/0",
        "pfe-9/3/0",
        "xe-9/3/0",
        "xe-9/3/1",
        "xe-9/3/2",
        "xe-9/3/3",
        "lc-10/0/0",
        "pfe-10/0/0",
        "pfh-10/0/0",
        "xe-10/0/0",
        "xe-10/0/1",
        "xe-10/0/2",
        "xe-10/0/3",
        "lc-10/1/0",
        "pfe-10/1/0",
        "xe-10/1/0",
        "xe-10/1/1",
        "xe-10/1/2",
        "xe-10/1/3",
        "lc-10/2/0",
        "pfe-10/2/0",
        "xe-10/2/0",
        "xe-10/2/1",
        "xe-10/2/2",
        "xe-10/2/3",
        "lc-10/3/0",
        "pfe-10/3/0",
        "xe-10/3/0",
        "xe-10/3/1",
        "xe-10/3/2",
        "xe-10/3/3",
        "lc-11/0/0",
        "pfe-11/0/0",
        "pfh-11/0/0",
        "xe-11/0/0",
        "xe-11/0/1",
        "xe-11/0/2",
        "xe-11/0/3",
        "et-11/1/0",
        "lc-11/2/0",
        "pfe-11/2/0",
        "xe-11/2/0",
        "xe-11/2/1",
        "xe-11/2/2",
        "xe-11/2/3",
        "et-11/3/0",
        ".local.",
        "ae0",
        "ae1",
        "ae2",
        "ae3",
        "ae4",
        "ae5",
        "ae6",
        "ae7",
        "ae8",
        "ae9",
        "ae10",
        "ae11",
        "ae12",
        "ae13",
        "ae14",
        "ae15",
        "ae16",
        "ae17",
        "ae18",
        "ae19",
        "ae20",
        "ae21",
        "ae22",
        "ae23",
        "ae24",
        "ae25",
        "ae26",
        "ae27",
        "ae28",
        "ae29",
        "ae30",
        "ae31",
        "ae32",
        "ae33",
        "ae34",
        "ae35",
        "ae36",
        "ae37",
        "ae38",
        "ae39",
        "ae40",
        "ae41",
        "ae42",
        "ae43",
        "ae44",
        "ae45",
        "ae46",
        "ae47",
        "ae48",
        "ae49",
        "ae50",
        "ae51",
        "ae52",
        "ae53",
        "ae54",
        "ae55",
        "ae56",
        "ae57",
        "ae58",
        "ae59",
        "ae60",
        "ae61",
        "ae62",
        "ae63",
        "as0",
        "as1",
        "as2",
        "as3",
        "as4",
        "as5",
        "as6",
        "as7",
        "as8",
        "as9",
        "as10",
        "as11",
        "as12",
        "as13",
        "as14",
        "as15",
        "cbp0",
        "demux0",
        "dsc",
        "em0",
        "em1",
        "fxp0",
        "gre",
        "ipip",
        "irb",
        "lo0",
        "lsi",
        "mtun",
        "pimd",
        "pime",
        "pip0",
        "pp0",
        "tap"
    ],
    "vendor": "Juniper",
    "serial_number": "JN11C2<REMOVED>",
    "model": "MX960",
    "hostname": "<REMOVED>",
    "fqdn": "<REMOVED>"
}
2017-11-02 14:19:48,815 - napalm - DEBUG - get_facts - Successful
2017-11-02 14:19:48,815 - napalm - DEBUG - method - Calling with args: (<napalm_junos.junos.JunOSDriver object at 0x105e9cc10>, 'get_optics'), {}
2017-11-02 14:19:48,815 - napalm - DEBUG - get_optics - Attempting to resolve method
2017-11-02 14:19:48,815 - napalm - DEBUG - get_optics - Attempting to call method with kwargs: {}
2017-11-02 14:19:50,150 - napalm - ERROR - method - Failed: could not convert string to float: - Inf

================= Traceback =================

Traceback (most recent call last):
  File "/Users/jboswell/.virtualenvs/nuke/bin/napalm", line 11, in <module>
    sys.exit(main())
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_base/clitools/cl_napalm.py", line 285, in main
    run_tests(args)
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_base/clitools/cl_napalm.py", line 268, in run_tests
    call_getter(device, args.method, **method_kwargs)
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_base/clitools/cl_napalm.py", line 27, in wrapper
    r = func(*args, **kwargs)
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_base/clitools/cl_napalm.py", line 238, in call_getter
    r = func(**kwargs)
  File "/Users/jboswell/.virtualenvs/nuke/lib/python2.7/site-packages/napalm_junos/junos.py", line 1785, in get_optics
    [None, C.OPTICS_NULL_LEVEL]
ValueError: could not convert string to float: - Inf
dbarrosop commented 7 years ago

We can probably do either optics['input_power'].replace(' ', '') in line 1879 or add a second constant. Do you want to try and submit a PR?

jamesboswell commented 6 years ago

@dbarrosop #521 submitted. I put the replace before the intf_optics dict, and only if input_power is a str

jamesboswell commented 6 years ago

I've changed my proposed fix to a new constant instead of a str replace, see #521