networktocode/ntc-templates

arista_eos_show_ip_route where IP routing is not enabled

Closed this issue · 2 comments

ISSUE TYPE
  • Bug Report
TEMPLATE USING
ceos1#show ip route vrf MGMT

VRF: MGMT
Codes: C - connected, S - static, K - kernel, 
       O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1,
       E2 - OSPF external type 2, N1 - OSPF NSSA external type 1,
       N2 - OSPF NSSA external type2, B - Other BGP Routes,
       B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1,
       I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate,
       A O - OSPF Summary, NG - Nexthop Group Static Route,
       V - VXLAN Control Service, M - Martian,
       DH - DHCP client installed default route,
       DP - Dynamic Policy Route, L - VRF Leaked,
       G  - gRIBI, RC - Route Cache Route

Gateway of last resort:
 S        0.0.0.0/0 [1/0] via 172.20.20.1, Management0

 C        172.20.20.0/24 is directly connected, Management0

! IP routing not enabled
SAMPLE COMMAND OUTPUT
[
	"State Error raised. Rule Line: 30. Input Line: ! IP routing not enabled"
]
SUMMARY

! IP routing not enabled is not being parsed correctly

STEPS TO REPRODUCE

Apply the template on the included output

EXPECTED RESULTS
[
	{
		"DIRECT": "",
		"DISTANCE": "1",
		"INTERFACE": [
			"Management0"
		],
		"MASK": "0",
		"METRIC": "0",
		"NETWORK": "0.0.0.0",
		"NEXT_HOP": [
			"172.20.20.1"
		],
		"PROTOCOL": "S",
		"VRF": "MGMT"
	},
	{
		"DIRECT": "directly",
		"DISTANCE": "",
		"INTERFACE": [
			"Management0"
		],
		"MASK": "24",
		"METRIC": "",
		"NETWORK": "172.20.20.0",
		"NEXT_HOP": [
			"connected"
		],
		"PROTOCOL": "C",
		"VRF": "MGMT"
	}
]
ACTUAL RESULTS
[
	"State Error raised. Rule Line: 30. Input Line: ! IP routing not enabled"
]

Given Arista EOS, only static and connected routes would be installed in the routing table if routing is not enabled. So we should not add any additional logic.

I think this would be the proper approach to ignore the line. Or maybe this was planned to error out on purpose.

We could introduce a key to the datamodel, but it would be odd to signify routing is disabled on an individual route as opposed to the vrf itself.

Value Filldown VRF (\S+)
Value PROTOCOL (\S+\s\S+?|\w?)
Value Required NETWORK (\d+\.\d+\.\d+\.\d+)
Value MASK (\d+)
Value DISTANCE (\d+)
Value METRIC (\d+)
Value DIRECT (directly)
Value Required,List NEXT_HOP (connected|\d+\.\d+\.\d+\.\d+)
#Value INTERFACE (\S+)
Value List INTERFACE (.+)

Start
  ^VRF(\s+name)?:\s+${VRF}\s*$$
  ^WARNING
  ^kernel
  ^Codes:
  # Match for codes
  ^\s+.+-.+
  ^\s*$$ -> Routes
  ^\! IP routing not enabled
  ^. -> Error

Routes
  ^\s+(\S+\s\S+?|\w?)\s+(\d+\.\d+\.\d+\.\d+)/(\d+)\s -> Continue.Record
  ^\s+${PROTOCOL}\s+${NETWORK}/${MASK}\s+is\s+${DIRECT}\s+${NEXT_HOP},\s+${INTERFACE}$$
  ^\s+${PROTOCOL}\s+${NETWORK}/${MASK}\s+(?:\[${DISTANCE}/${METRIC}\]|is\s+${DIRECT})(?:.+?)${NEXT_HOP},\s+${INTERFACE}$$
  ^\s+via\s+${NEXT_HOP},\s+${INTERFACE}
  ^\s*$$ -> Record
  ^VRF(\s+name)?:\s+${VRF}\s*$$ -> Start
  ^Gateway\s+of\s+last
  ^\! IP routing not enabled
  ^. -> Error

I will raise a PR.