networktocode/ntc-templates

cisco ASA show route textfsm: State error

Closed this issue · 4 comments

While trying to parse cisco_asa show route getting this error:

textfsm.parser.TextFSMError: State Error raised. Rule Line: 12. Input Line: Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

The template is

Value Filldown PROTOCOL (C|S|R|B|D|O|i|L)
Value Filldown TYPE (\w{0,2})
Value Required,Filldown NETWORK (\d+\.\d+\.\d+\.\d+|\S+)
Value Filldown MASK (\d+\.\d+\.\d+\.\d+)
Value DISTANCE (\d+)
Value METRIC (\d+)
Value NEXTHOPIP (\d+\.\d+\.\d+\.\d+)
Value NEXTHOPIF (\S+)
Value UPTIME (\d\S+?)

Start
  ^Gateway -> ROUTES

ROUTES
  # Match regular routes with all data in same line
  ^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${MASK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOPIP}(,\s${UPTIME}){0,1}(,\s${NEXTHOPIF}){0,1}\s*$$ -> Record
  #
  # Clear all non Filldown variables when line started with network that is variably subnetted
  ^\s+[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}${MASK}\s*$$ -> Clear
  ^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOPIP}(,\s${UPTIME}){0,1}(,\s${NEXTHOPIF}){0,1}\s*$$ -> Record
  #
  # Match multiline route statements
  ^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${MASK}\s*$$
  #
  # Match load-balanced routes
  ^\s+\[${DISTANCE}\/${METRIC}\]\s+via\s+${NEXTHOPIP},(?:\s+${UPTIME},)?\s+${NEXTHOPIF}\s*$$ -> Record
  #
  # Match directly connected routes
  ^${PROTOCOL}\s${TYPE}\s+${NETWORK}\sis\sdirectly\sconnected,\s${NEXTHOPIF} -> Record
  ^${PROTOCOL}(\*){0,1}\s${TYPE}\s+${NETWORK}\s+${MASK}\sis\sdirectly\sconnected,\s${NEXTHOPIF} -> Record
  #
  # Clear all variables on empty lines
  ^\s* -> Clearall
  #^${TYPE} -> Continue.Record
  #^${TYPE}\s+${NETWORK}\s+${MASK}\s+\[\d+\/\d+\]\s+via\s+${GATEWAY}\,\s+${UPTIME},\s+${INTFC}\s*$$ -> Record
  #^\s+\[\d+\/\d+\]\s+via\s+${GATEWAY}\,\s+${UPTIME},\s+${INTFC}\s*$$ -> Record

EOF

sample data:

> show route 

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, V - VPN
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, + - replicated route
       SI - Static InterVRF
Gateway of last resort is 192.168.10.2 to network 0.0.0.0

S*       0.0.0.0 0.0.0.0 [1/0] via 192.168.10.2, Outside
B        10.0.0.0 255.0.0.0 [200/4] via 10.226.20.254, 1d11h
C        10.1.119.248 255.255.255.252 
           is directly connected, Unit-Failover-Interface
L        10.1.119.249 255.255.255.255 
           is directly connected, Unit-Failover-Interface
mjbear commented

@mksbcisco
Is this still occurring?
I cannot replicate this with the example output that is on this issue.

@mksbcisco
Would you please respond whether this issue is still happening for you?

I cannot replicate the problem.
And there haven't been many changes to that template either.
https://github.com/networktocode/ntc-templates/commits/master/ntc_templates/templates/cisco_asa_show_route.textfsm

@mksbcisco
Given the template status in January 2023, I'm not sure how that error could have been occurring. The ^. -> Error lines required by this ntc-templates project weren't added until March 2024 via PR #1636.

The rest of the earlier git history does not show any signs of there being a problem. Nor could I replicate it in August 2023.

unable to reproduce issue, and lack of response