guides:user:scenarios:cmd_parse_juniper
Differences
This shows you the differences between two versions of the page.
| guides:user:scenarios:cmd_parse_juniper [2019/12/24 08:32] – created bdorlandt | guides:user:scenarios:cmd_parse_juniper [2024/07/03 12:31] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== 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 " | ||
| + | |||
| + | < | ||
| + | ! | ||
| + | </ | ||
| + | |||
| + | ==== 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: < | ||
| + | </ | ||
| + | |||
| + | ==== 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 < | ||
| + | | ||
| + | stop | ||
| + | endif | ||
| + | LogAction -n < | ||
| + | |||
| + | < | ||
| + | if < | ||
| + | # The Juniper will provide an error if the interface and subinterface don't exist. | ||
| + | < | ||
| + | else | ||
| + | log -m " | ||
| + | < | ||
| + | stop | ||
| + | endif | ||
| + | |||
| + | < | ||
| + | if < | ||
| + | # The Juniper will provide an error if the interface and subinterface don't exist. | ||
| + | < | ||
| + | else | ||
| + | log -m " | ||
| + | < | ||
| + | stop | ||
| + | endif | ||
| + | |||
| + | < | ||
| + | if < | ||
| + | log -m "Show bgp neighbor gave an error. Will stop." | ||
| + | < | ||
| + | stop | ||
| + | endif | ||
| + | if < | ||
| + | log -m "BGP neighbor already exists. < | ||
| + | < | ||
| + | stop | ||
| + | else | ||
| + | < | ||
| + | endif | ||
| + | |||
| + | # Create the configuration using the template " | ||
| + | # " | ||
| + | config_create -n < | ||
| + | if < | ||
| + | Logaction -n < | ||
| + | Stop | ||
| + | endif | ||
| + | |||
| + | config_exec -n < | ||
| + | if < | ||
| + | Logaction -n < | ||
| + | Stop | ||
| + | endif | ||
| + | </ | ||