===== Command parsing on Juniper for interfaces and BGP =====
Create a new Command Job and save it using a desired name.
==== Command Job ====
The job is "empty". It still requires something though, so it's filled with a '!'.
!
==== Parsing template basic_error_check ====
You'll see in the command parsing that no checks are needed since we expect an error as a result. (This is specifically the case for Juniper when applying a show command for which it can't find a result)
!
==== Parsing template show_bgp_neighbor ====
The static values are: //Peer:// and //AS//. Everything behind //AS// is ignored. The //peerip// variable is filled with anything up to the word AS.
Peer: AS |*|
==== Job scenario ====
# Some variables that are needed in the chained task and templates.
cpe_hostname := CPE-name
Vrf_id := 12345
# These variables are retrieved without additional input.
pe :=
PE_interface :=
sub_int1 :=
sub_int2 :=
cpe_ip :=
Description PE parsing and configuration on
task := scn_pe_config
==== Scenario scn_pe_config ====
Description PE parsing checks on
# Test whether node is live and reachable
reachable -n
if
LogAction -n -a Command_job -m " is not reachable"
stop
endif
LogAction -n -a Command_job -m " is reachable"
<%cmd> := Parse_cmd -n -t basic_error_check -r "show interfaces ."
if
# The Juniper will provide an error if the interface and subinterface don't exist.
:= "1"
else
log -m "Interface exists. Will stop."
:= "0"
stop
endif
<%cmd> := Parse_cmd -n -t basic_error_check -r "show interfaces ."
if
# The Juniper will provide an error if the interface and subinterface don't exist.
:= "1"
else
log -m "Interface exists. Will stop."
:= "0"
stop
endif
<%cmd> := Parse_cmd -n -t show_bgp_neighbor -r "show bgp neighbor "
if
log -m "Show bgp neighbor gave an error. Will stop."
:= "0"
stop
endif
if
log -m "BGP neighbor already exists. ."
:= "0"
stop
else
:= "1"
endif
# Create the configuration using the template "PE_CPE" and provide the parameters
# "cpe_hostname" and "Vrf_id". These are required for the relation used within the template.
config_create -n -t PE_CPE
if
Logaction -n -m "Failed to create PE commands for CPE "
Stop
endif
config_exec -n
if
Logaction -n -m "Failed to configure PE commands for CPE "
Stop
endif