ntc-templates icon indicating copy to clipboard operation
ntc-templates copied to clipboard

cisco_nxos_show_interface_transciever parsing issue

Open Tes3awy opened this issue 9 months ago • 5 comments

ISSUE TYPE
  • Template Issue with error and raw data
  • Bug Report with the library
TEMPLATE USING
Value INTERFACE (\S+/\S+)
Value MANUFACTURER (\S+)
Value TYPE (.+)
Value SERIAL (\S+)
Value PART_NUMBER (\S+)

Start
  ^${INTERFACE}
  ^\s+transceiver is not -> Clear
  ^\s+type\s+is(\s+${TYPE})?
  ^\s+name\s+is(\s+${MANUFACTURER})?
  ^\s+part\s+number\s+is(\s+${PART_NUMBER})?
  ^\s+serial\s+number\s+is(\s+${SERIAL})?
  ^\s+transceiver\s+
  ^\s+nominal\s+
  ^\s+revision\s+
  ^\s+Link\s+
  ^\s+cable\s+type\s+is
  ^\s+cisco\s+id
  ^\s+cisco\s+extended
  ^\s+cisco\s+part\s+number
  ^\s+cisco\s+product\s+id
  ^\s+cisco\s+version\s+id
  ^\s*$$ -> Record
  ^. -> Error
SAMPLE COMMAND OUTPUT
Ethernet1/1
    transceiver is not applicable

Ethernet1/2
    transceiver is not applicable

Ethernet1/3
    transceiver is not applicable

Ethernet1/4
    transceiver is not applicable

Ethernet1/5
    transceiver is not applicable

Ethernet1/6
    transceiver is not applicable

Ethernet1/7
    transceiver is not applicable

Ethernet1/8
    transceiver is not applicable

Ethernet1/9
    transceiver is not applicable

Ethernet1/10
    transceiver is not applicable

Ethernet1/11
    transceiver is not applicable

Ethernet1/12
    transceiver is not applicable

Ethernet1/13
    transceiver is not applicable

Ethernet1/14
    transceiver is not applicable

Ethernet1/15
    transceiver is not applicable

Ethernet1/16
    transceiver is not applicable

Ethernet1/17
    transceiver is not applicable

Ethernet1/18
    transceiver is not applicable

Ethernet1/19
    transceiver is not applicable

Ethernet1/20
    transceiver is not applicable

Ethernet1/21
    transceiver is not applicable

Ethernet1/22
    transceiver is not applicable

Ethernet1/23
    transceiver is not applicable

Ethernet1/24
    transceiver is not applicable

Ethernet1/25
    transceiver is not applicable

Ethernet1/26
    transceiver is not applicable

Ethernet1/27
    transceiver is not applicable

Ethernet1/28
    transceiver is not applicable

Ethernet1/29
    transceiver is not applicable

Ethernet1/30
    transceiver is not applicable

Ethernet1/31
    transceiver is not applicable

Ethernet1/32
    transceiver is not applicable

Ethernet1/33
    transceiver is not applicable

Ethernet1/34
    transceiver is not applicable

Ethernet1/35
    transceiver is not applicable

Ethernet1/36
    transceiver is not applicable

Ethernet1/37
    transceiver is not applicable

Ethernet1/38
    transceiver is not applicable

Ethernet1/39
    transceiver is not applicable

Ethernet1/40
    transceiver is not applicable

Ethernet1/41
    transceiver is not applicable

Ethernet1/42
    transceiver is not applicable

Ethernet1/43
    transceiver is not applicable

Ethernet1/44
    transceiver is not applicable

Ethernet1/45
    transceiver is not applicable

Ethernet1/46
    transceiver is not applicable

Ethernet1/47
    transceiver is not applicable

Ethernet1/48
    transceiver is not applicable

Ethernet1/49
    transceiver is not applicable

Ethernet1/50
    transceiver is not applicable

Ethernet1/51
    transceiver is not applicable

Ethernet1/52
    transceiver is not applicable

Ethernet1/53
    transceiver is not applicable

Ethernet1/54
    transceiver is not applicable

Ethernet1/55
    transceiver is not applicable

Ethernet1/56
    transceiver is not applicable

Ethernet1/57
    transceiver is not applicable

Ethernet1/58
    transceiver is not applicable

Ethernet1/59
    transceiver is not applicable

Ethernet1/60
    transceiver is not applicable

Ethernet1/61
    transceiver is not applicable

Ethernet1/62
    transceiver is not applicable

Ethernet1/63
    transceiver is not applicable

Ethernet1/64
    transceiver is not applicable

SUMMARY

Cannot parse Nexus 9000 show interface transciever output.

STEPS TO REPRODUCE
from pprint import pprint

from netmiko import ConnectHandler
from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutException

device = {
    "device_type": "cisco_nxos",
    "ip": "sbx-nxos-mgmt.cisco.com",
    "username": "admin",
    "password": "Admin_1234!",
    "secret": "",
    "fast_cli": False,
}

try:
    print(f"Trying {device['ip']}...", end="\r")
    conn = ConnectHandler(**device)
    print(f"Connected to {conn.host}:{conn.port}")
    if not conn.check_enable_mode():
        conn.enable()
    transceivers = conn.send_command(
        command_string="show interface transceiver", use_textfsm=True
    )
except (
    NetmikoAuthenticationException,
    NetmikoTimeoutException,
    ConnectionResetError,
    TimeoutError,
) as e:
    print(f"Failed to connect to {device['ip']} due to {type(e).__name__}: {e}")
else:
    conn.disconnect()
    pprint(transceivers)



EXPECTED RESULTS
ACTUAL RESULTS
Ethernet1/1
    transceiver is not applicable

Ethernet1/2
    transceiver is not applicable

Ethernet1/3
    transceiver is not applicable

Ethernet1/4
    transceiver is not applicable

Ethernet1/5
    transceiver is not applicable

Ethernet1/6
    transceiver is not applicable

Ethernet1/7
    transceiver is not applicable

Ethernet1/8
    transceiver is not applicable

Ethernet1/9
    transceiver is not applicable

Ethernet1/10
    transceiver is not applicable

Ethernet1/11
    transceiver is not applicable

Ethernet1/12
    transceiver is not applicable

Ethernet1/13
    transceiver is not applicable

Ethernet1/14
    transceiver is not applicable

Ethernet1/15
    transceiver is not applicable

Ethernet1/16
    transceiver is not applicable

Ethernet1/17
    transceiver is not applicable

Ethernet1/18
    transceiver is not applicable

Ethernet1/19
    transceiver is not applicable

Ethernet1/20
    transceiver is not applicable

Ethernet1/21
    transceiver is not applicable

Ethernet1/22
    transceiver is not applicable

Ethernet1/23
    transceiver is not applicable

Ethernet1/24
    transceiver is not applicable

Ethernet1/25
    transceiver is not applicable

Ethernet1/26
    transceiver is not applicable

Ethernet1/27
    transceiver is not applicable

Ethernet1/28
    transceiver is not applicable

Ethernet1/29
    transceiver is not applicable

Ethernet1/30
    transceiver is not applicable

Ethernet1/31
    transceiver is not applicable

Ethernet1/32
    transceiver is not applicable

Ethernet1/33
    transceiver is not applicable

Ethernet1/34
    transceiver is not applicable

Ethernet1/35
    transceiver is not applicable

Ethernet1/36
    transceiver is not applicable

Ethernet1/37
    transceiver is not applicable

Ethernet1/38
    transceiver is not applicable

Ethernet1/39
    transceiver is not applicable

Ethernet1/40
    transceiver is not applicable

Ethernet1/41
    transceiver is not applicable

Ethernet1/42
    transceiver is not applicable

Ethernet1/43
    transceiver is not applicable

Ethernet1/44
    transceiver is not applicable

Ethernet1/45
    transceiver is not applicable

Ethernet1/46
    transceiver is not applicable

Ethernet1/47
    transceiver is not applicable

Ethernet1/48
    transceiver is not applicable

Ethernet1/49
    transceiver is not applicable

Ethernet1/50
    transceiver is not applicable

Ethernet1/51
    transceiver is not applicable

Ethernet1/52
    transceiver is not applicable

Ethernet1/53
    transceiver is not applicable

Ethernet1/54
    transceiver is not applicable

Ethernet1/55
    transceiver is not applicable

Ethernet1/56
    transceiver is not applicable

Ethernet1/57
    transceiver is not applicable

Ethernet1/58
    transceiver is not applicable

Ethernet1/59
    transceiver is not applicable

Ethernet1/60
    transceiver is not applicable

Ethernet1/61
    transceiver is not applicable

Ethernet1/62
    transceiver is not applicable

Ethernet1/63
    transceiver is not applicable

Ethernet1/64
    transceiver is not applicable

Tes3awy avatar Oct 01 '23 21:10 Tes3awy