networktocode/ntc-templates

Invalid Parsed on cisco_xr_show_interfaces.textfsm using GO language

Closed this issue · 1 comments

ISSUE TYPE
  • Bug Report
TEMPLATE USING
Value Required INTERFACE (\S+)
Value LINK_STATUS (.+?)
Value ADMIN_STATE (.+?)
Value HARDWARE_TYPE (\S+?(?:\s+Ethernet|))
Value ADDRESS ((?:\w{4}\.){2}\w{4})
Value BIA ((?:\w{4}\.){2}\w{4})
Value DESCRIPTION (.*?)
Value IP_ADDRESS (.*?)
Value MTU (\d+)
Value DUPLEX (.+?)
Value SPEED (.+?b/s)
Value BANDWIDTH (\d+\s+\w+)
Value ENCAPSULATION (\w+)

Start
  ^\S+\s+is -> Continue.Record
  ^${INTERFACE}\sis\s+${LINK_STATUS},\s+line\sprotocol\sis\s+${ADMIN_STATE}\s*$$
  ^\s+Hardware\s+is\s+${HARDWARE_TYPE}(?:\s+interface\(s\)|)(?:,\s+address\s+is\s+${ADDRESS}(?:\s+\(bia\s+${BIA}\)\s*)*$$|\s.+|\s*$$)
  ^\s+Description:\s+${DESCRIPTION}\s*$$
  ^\s+[Ii]nternet\s+[Aa]ddress\s+is\s+${IP_ADDRESS}\s*$$
  ^\s+MTU\s+${MTU}.*BW\s+${BANDWIDTH}
  ^\s+Encapsulation\s+${ENCAPSULATION}
  ^\s+(?:[Dd]uplex\s+|)${DUPLEX}(?:-[Dd]uplex|),\s+${SPEED}

SAMPLE COMMAND OUTPUT
Loopback0 is up, line protocol is up 
  Interface state transitions: 1
  Hardware is Loopback interface(s)
  Internet address is 114.1.201.76/32
  MTU 1500 bytes, BW 0 Kbit
     reliability Unknown, txload Unknown, rxload Unknown
  Encapsulation Loopback,  loopback not set,
  Last link flapped 10w1d
  Last input Unknown, output Unknown
  Last clearing of "show interface" counters Unknown
  Input/output data rate is disabled.

SUMMARY
STEPS TO REPRODUCE
r, _ := driver.SendCommand("show interfaces")
	parsedOut, err := r.TextFsmParse("ntc-templates/ntc_templates/templates/cisco_xr_show_interfaces.textfsm")
	if err != nil {
		err_str := "failed to parse show interfaces command"
		fmt.Printf("%v; error: %+v\n", err_str, err)
		return []map[string]interface{}{}, errors.New(err_str)
	}

	return parsedOut, nil

EXPECTED RESULTS
map[
ADDRESS:f04a.0290.3300 
ADMIN_STATE:up 
BANDWIDTH:0 Kbit 
BIA:f04a.0290.3300 
DESCRIPTION: "" 
DUPLEX:Full 
ENCAPSULATION:Loopback 
HARDWARE_TYPE:Loopback 
INTERFACE:Loopback0 
IP_ADDRESS:114.1.201.76/32 
LINK_STATUS:up 
MTU:1500 
SPEED:1000Mb/s] 
ACTUAL RESULTS
map[
ADDRESS:f04a.0290.3300 
ADMIN_STATE:up 
BANDWIDTH:0 Kbit 
BIA:f04a.0290.3300 
DESCRIPTION:"PT PANIN BANK" 
DUPLEX:Full 
ENCAPSULATION:Loopback 
HARDWARE_TYPE:Loopback 
INTERFACE:Loopback0 
IP_ADDRESS:114.1.201.76/32 
LINK_STATUS:up 
MTU:1500 
SPEED:1000Mb/s] 

It is unclear which golang library you are using, but I would refer to them. The templates are all ran via testing, so this would not be an issue with this repo.