Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cisco_nxos_show_interface_transceiver.textfsm Not parsing without spaces between interfaces. #2017

Closed
Mikeg2881 opened this issue Feb 7, 2025 · 4 comments · Fixed by #2018

Comments

@Mikeg2881
Copy link

It appears NX-OS will return this (show interface transceiver) command different depending on Model/Version
Sometimes its 1 continuous line of text. Sometimes there is a space before every "Ethernet" Line. The module seems to work only if there is a space between the lines.
ntc_templates 7.6.0 (Upgraded to 7.7.0 and still have this error)

Sample show command output that works

Ethernet3/1
    transceiver is not present

Ethernet3/2
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTRJ8519P1BNL-C4
    revision is A   
    serial number is FNS1009J3MT     
    nominal bitrate is 2100 MBit/sec
    cisco id is 3
    cisco extended id number is 4

Ethernet3/3
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R416     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01 

Ethernet3/4
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R41D     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01`

The output from the Parsing is:
[{'interface': 'Ethernet3/1', 'status': 'not present', 'manufacturer': '', 'type': '', 'serial': '', 'part_number': '', 'product_id': ''}, {'interface': 'Ethernet3/2', 'status': 'present', 'manufacturer': 'CISCO-FINISAR', 'type': '1000base-SX', 'serial': 'FNS1009J3MT', 'part_number': 'FTRJ8519P1BNL-C4', 'product_id': ''}, {'interface': 'Ethernet3/3', 'status': 'present', 'manufacturer': 'CISCO', 'type': '1000base-SX', 'serial': 'AGJ1945R416', 'part_number': 'SFBR-5716PZ', 'product_id': 'GLC-SX-MMD'}, {'interface': 'Ethernet3/4', 'status': 'present', 'manufacturer': 'CISCO', 'type': '1000base-SX', 'serial': 'AGJ1945R41D', 'part_number': 'SFBR-5716PZ', 'product_id': 'GLC-SX-MMD'}]

Sample show command output that doesn't work

Ethernet3/1
    transceiver is not present
Ethernet3/2
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTRJ8519P1BNL-C4
    revision is A   
    serial number is FNS1009J3MT     
    nominal bitrate is 2100 MBit/sec
    cisco id is 3
    cisco extended id number is 4
Ethernet3/3
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R416     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01 
Ethernet3/4
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R41D     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01

The output from the Parsing is:
[{'interface': 'Ethernet3/4', 'status': 'present', 'manufacturer': 'CISCO', 'type': '1000base-SX', 'serial': 'AGJ1945R41D', 'part_number': 'SFBR-5716PZ', 'product_id': 'GLC-SX-MMD'}]

Code to reproduce:

platform="cisco_nxos"

interface_output_example_1 = """
Ethernet3/1
    transceiver is not present
Ethernet3/2
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTRJ8519P1BNL-C4
    revision is A   
    serial number is FNS1009J3MT     
    nominal bitrate is 2100 MBit/sec
    cisco id is 3
    cisco extended id number is 4
Ethernet3/3
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R416     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01 
Ethernet3/4
    transceiver is present
    type is 1000base-SX
    name is CISCO           
    part number is SFBR-5716PZ     
    revision is 001 
    serial number is AGJ1945R41D     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2626-01
    cisco product id is GLC-SX-MMD          
    cisco vendor id is V01 

"""



print("")
interfaces_parsed = parse_output(platform=platform, command="show interface transceiver", data=interface_output_example_1)
print(interfaces_parsed)
print("===========================")
@mjbear
Copy link
Collaborator

mjbear commented Feb 7, 2025

It appears NX-OS will return this (show interface transceiver) command different depending on Model/Version Sometimes its 1 continuous line of text. Sometimes there is a space before every "Ethernet" Line. The module seems to work only if there is a space between the lines. ntc_templates 7.6.0 (Upgraded to 7.7.0 and still have this error)

I see what you're pointing out.
The template as it currently exists, Records when it hits blank lines.

https://github.com/networktocode/ntc-templates/blob/master/ntc_templates/templates/cisco_nxos_show_interface_transceiver.textfsm#L27

@mjbear
Copy link
Collaborator

mjbear commented Feb 7, 2025

@Mikeg2881
Are you able to share which Nexus hardware models and NXOS versions have blank spaces in between and which don't?

@Mikeg2881
Copy link
Author

Mikeg2881 commented Feb 7, 2025

Digging into this...

Returns a space between every line
C93180YC-EX-version 9.3(11) :
Nexus 5596 7.0(8)N1(1)
Nexus9000 C9508 version 10.4(3)
Examples below:

Ethernet1/1
    transceiver is present
    type is 1000base-T
    name is CISCO-METHODE
    part number is SP7041_Rev_F
    revision is F
    serial number is 00000MTC17280FVM
    nominal bitrate is 1300 MBit/sec
    Link length supported for copper is 100 m
    cisco id is 3
    cisco extended id number is 4

Ethernet1/2
    transceiver is present
    type is 1000base-T
    name is CISCO-METHODE
    part number is SP7041-SBU
    revision is B
    serial number is MTC110803SP
    nominal bitrate is 1300 MBit/sec
    Link length supported for copper is 100 m
    cisco id is 3
    cisco extended id number is 4

Ethernet1/3
    transceiver is present
    type is SFP-H10GB-CU3M
    name is CISCO-TYCO
    part number is 1-2053783-2
    revision is T
    serial number is TED1936B0FT
    nominal bitrate is 10300 MBit/sec
    Link length supported for copper is 3 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 37-0961-03
    cisco product id is SFP-H10GB-CU3M
    cisco version id is V03

Returns a space ONLY after interfaces with no transceivers
Nexus7000 C7009 version 8.4(6a)
Nexus7700 C7706 version 7.2(0)D1(1)
Nexus7700 C7710 version 8.4(6a)
Nexus7700 C7710 version 8.4(3)
Examples below:

Ethernet1/1
    transceiver is present
    type is SFP-10G-BXD-I
    name is CISCO-FINISAR   
    part number is FTLX2071D333-CS 
    revision is A   
    serial number is FNS19040ADP     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 9/125um fiber is 10 km
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2952-01
    cisco product id is SFP-10G-BXD-I       
    cisco vendor id is V01 
Ethernet1/2
    transceiver is not present

Ethernet1/3
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR1823G5X1     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/4
    transceiver is present
    type is 1000base-SX
    name is CISCO-AVAGO     
    part number is SFBR-5766PZ     
    revision is     
    serial number is AGM121618WX     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
Ethernet1/5
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS1 
    revision is G4.1
    serial number is AVD1945ADTG     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/6
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS1 
    revision is G4.1
    serial number is AVD2029A580     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/7
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR2027GAHD     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/8
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTLF8519P2BCL-CS
    revision is B   
    serial number is FNS124215WK     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 30-1301-02
    cisco product id is                     
    cisco vendor id is V01 
Ethernet1/9
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR2028GEED     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/10
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS1 
    revision is G4.1
    serial number is AVD2029A59E     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/11
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR2028G8HX     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/12
    transceiver is present
    type is 10Gbase-SR
    name is FINISAR CORP.   
    part number is FTLX8574D3BNL-E5
    revision is A1  
    serial number is AYQ1TT3         
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/13
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR1823G34B     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/14
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS1 
    revision is G4.1
    serial number is AVD1944A4PN     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/15
    transceiver is present
    type is 10Gbase-SR
    name is FORTINET        
    part number is FTLX8574D3BCLFTN
    revision is A   
    serial number is N5KCXNG         
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/16
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTLF8519P2BCL-CS
    revision is 0000
    serial number is FNS123501FG     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 30-1301-02
    cisco product id is                     
    cisco vendor id is V01 
Ethernet1/17
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR1823G3H3     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/18
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTLF8519P2BNL-CS
    revision is 0000
    serial number is FNS1024D42K     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 30-1301-02
    cisco product id is                     
    cisco vendor id is V01 
Ethernet1/19
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS1 
    revision is G4.1
    serial number is AVD2110A7B8     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/20
    transceiver is present
    type is 1000base-SX
    name is CISCO-FINISAR   
    part number is FTLF8519P2BCL-CS
    revision is 0000
    serial number is FNS113508LW     
    nominal bitrate is 1300 MBit/sec
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 30-1301-02
    cisco product id is                     
    cisco vendor id is V01 
Ethernet1/21
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS2 
    revision is G4.1
    serial number is AVD2213D655     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-3105-01
    cisco product id is SFP-10G-SR-S        
    cisco vendor id is V01 
Ethernet1/22
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-AVAGO     
    part number is SFBR-709SMZ-CS2 
    revision is G4.1
    serial number is AVD2213D64V     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-3105-01
    cisco product id is SFP-10G-SR-S        
    cisco vendor id is V01 
Ethernet1/23
    transceiver is present
    type is 10Gbase-SR
    name is Intel Corp      
    part number is FTLX8571D3BCV-IT
    revision is A   
    serial number is INSSRJ90406     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/24
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-OPLINK    
    part number is TPP4XGDS0CCISE2G
    revision is 02  
    serial number is OPM250101F5     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/25
    transceiver is present
    type is SFP-H10GB-CU3M
    name is CISCO-TYCO      
    part number is 1-2053783-2     
    revision is T   
    serial number is TED1943B22T     
    nominal bitrate is 10300 MBit/sec
    Link length supported for copper is 3 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/26
    transceiver is present
    type is SFP-H10GB-CU3M
    name is CISCO-TYCO      
    part number is 1-2053783-2     
    revision is T   
    serial number is TED1943B1KA     
    nominal bitrate is 10300 MBit/sec
    Link length supported for copper is 3 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/27
    transceiver is present
    type is SFP-H10GB-CU3M
    name is CISCO-TYCO      
    part number is 1-2053783-2     
    revision is T   
    serial number is TED1943B05R     
    nominal bitrate is 10300 MBit/sec
    Link length supported for copper is 3 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/28
    transceiver is present
    type is SFP-H10GB-CU3M
    name is CISCO-TYCO      
    part number is 1-2053783-2     
    revision is T   
    serial number is TED1943B1K9     
    nominal bitrate is 10300 MBit/sec
    Link length supported for copper is 3 m
    cisco id is 3
    cisco extended id number is 4
Ethernet1/29
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-JDSU      
    part number is PLRXPL-SC-S43-CS
    revision is 1   
    serial number is JUR1825G02R     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 
Ethernet1/30
    transceiver is not present

Ethernet1/31
    transceiver is present
    type is 10Gbase-SR
    name is CISCO-OPLINK    
    part number is TPP4XGDS0CCISE2G
    revision is 02  
    serial number is OPM250101FA     
    nominal bitrate is 10300 MBit/sec
    Link length supported for 50/125um OM2 fiber is 82 m
    Link length supported for 62.5/125um fiber is 26 m
    Link length supported for 50/125um OM3 fiber is 300 m
    cisco id is 3
    cisco extended id number is 4
    cisco part number is 10-2415-03
    cisco product id is SFP-10G-SR          
    cisco vendor id is V03 

@mjbear
Copy link
Collaborator

mjbear commented Feb 7, 2025

Digging into this...

Returns a space between every line C93180YC-EX-version 9.3(11) : Nexus 5596 7.0(8)N1(1) Nexus9000 C9508 version 10.4(3) Examples below:

Returns a space ONLY after interfaces with no transceivers Nexus7000 C7009 version 8.4(6a) Nexus7700 C7706 version 7.2(0)D1(1) Nexus7700 C7710 version 8.4(6a) Nexus7700 C7710 version 8.4(3) Examples below:

Appreciated.

Seems like there's two instances of 7k output, one with a blank space after "no transceivers" and another without the blank line. That can be supported either way. 🙂

Ok, so the Nexus 5k and 9k behave one way and the Nexus 7k seems to be the outlier.
It turns out this format was supported starting with #564 which also fixes this scenario.

I worked up PR #2018 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants