Skip to content

Commit

Permalink
Juniper parsing: handle empty lines with trailing spaces (#3658)
Browse files Browse the repository at this point in the history
  • Loading branch information
progwriter committed Apr 19, 2019
1 parent 7e04ed3 commit ee34ac2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ deactivate_line_tail

flat_juniper_configuration
:
NEWLINE?
(
deactivate_line
| protect_line
| set_line
)+ NEWLINE? EOF
| newline
)+ EOF
;

newline
:
NEWLINE
;

protect_line
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# RANCID-CONTENT-TYPE: juniper
#
set system host-name juniper_trailing_space
set routing-options router-id 1.1.1.1
! next line contains a trailing space

set routing-options autonomous-system 1
45 changes: 45 additions & 0 deletions tests/parsing-tests/unit-tests-nodes.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25515,6 +25515,51 @@
}
}
},
"juniper_trailing_space" : {
"configurationFormat" : "FLAT_JUNIPER",
"name" : "juniper_trailing_space",
"defaultCrossZoneAction" : "PERMIT",
"defaultInboundAction" : "PERMIT",
"deviceType" : "SWITCH",
"vendorFamily" : {
"juniper" : {
"lines" : {
"auxiliary" : {
"name" : "auxiliary",
"aaaAuthenticationLoginList" : {
"methods" : [
"PASSWORD"
]
},
"execTimeoutMinutes" : 0,
"execTimeoutSeconds" : 0,
"lineType" : "AUX"
},
"console" : {
"name" : "console",
"aaaAuthenticationLoginList" : {
"methods" : [
"PASSWORD"
]
},
"execTimeoutMinutes" : 0,
"execTimeoutSeconds" : 0,
"lineType" : "CON"
}
},
"systemAuthenticationOrder" : {
"methods" : [
"PASSWORD"
]
}
}
},
"vrfs" : {
"default" : {
"name" : "default"
}
}
},
"juniper_vlan" : {
"configurationFormat" : "FLAT_JUNIPER",
"name" : "juniper_vlan",
Expand Down
51 changes: 51 additions & 0 deletions tests/parsing-tests/unit-tests.ref
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@
"juniper_tacplus" : [
"configs/juniper_tacplus"
],
"juniper_trailing_space" : [
"configs/juniper_trailing_space"
],
"juniper_vlan" : [
"configs/juniper_vlan"
],
Expand Down Expand Up @@ -1116,6 +1119,7 @@
"configs/juniper_syslog" : "PASSED",
"configs/juniper_system" : "PASSED",
"configs/juniper_tacplus" : "PASSED",
"configs/juniper_trailing_space" : "PASSED",
"configs/juniper_vlan" : "PASSED",
"configs/local_v6_addr" : "PASSED",
"configs/mac_access_list" : "PASSED",
Expand Down Expand Up @@ -66914,6 +66918,50 @@
" EOF:<EOF>)"
]
},
"configs/juniper_trailing_space" : {
"sentences" : [
"(flat_juniper_configuration",
" (set_line",
" SET:'set'",
" (set_line_tail",
" (statement",
" (s_common",
" (s_system",
" SYSTEM:'system'",
" (sy_host_name",
" HOST_NAME:'host-name'",
" (variable",
" text = VARIABLE:'juniper_trailing_space'))))))",
" NEWLINE:'\\n')",
" (set_line",
" SET:'set'",
" (set_line_tail",
" (statement",
" (s_common",
" (s_routing_options",
" ROUTING_OPTIONS:'routing-options'",
" (ro_router_id",
" ROUTER_ID:'router-id'",
" id = IP_ADDRESS:'1.1.1.1')))))",
" NEWLINE:'\\n')",
" (newline",
" NEWLINE:'\\n')",
" (set_line",
" SET:'set'",
" (set_line_tail",
" (statement",
" (s_common",
" (s_routing_options",
" ROUTING_OPTIONS:'routing-options'",
" (ro_autonomous_system",
" AUTONOMOUS_SYSTEM:'autonomous-system'",
" asn = (bgp_asn",
" asn = DEC:'1')",
" (apply))))))",
" NEWLINE:'\\n\\n')",
" EOF:<EOF>)"
]
},
"configs/juniper_vlan" : {
"sentences" : [
"(flat_juniper_configuration",
Expand Down Expand Up @@ -74585,6 +74633,7 @@
"juniper_syslog" : "PASSED",
"juniper_system" : "PASSED",
"juniper_tacplus" : "PASSED",
"juniper_trailing_space" : "PASSED",
"juniper_vlan" : "PASSED",
"l2vpn" : "PASSED",
"local_v6_addr" : "PASSED",
Expand Down Expand Up @@ -80305,6 +80354,7 @@
}
},
"configs/juniper_tacplus" : { },
"configs/juniper_trailing_space" : { },
"configs/juniper_vlan" : {
"interface" : {
"xe-0/0/0" : {
Expand Down Expand Up @@ -88274,6 +88324,7 @@
"configs/juniper_syslog" : "PASSED",
"configs/juniper_system" : "PASSED",
"configs/juniper_tacplus" : "PASSED",
"configs/juniper_trailing_space" : "PASSED",
"configs/juniper_vlan" : "PASSED",
"configs/local_v6_addr" : "PASSED",
"configs/mac_access_list" : "PASSED",
Expand Down

0 comments on commit ee34ac2

Please sign in to comment.