execute
The execute command runs a specified command on the device loaded in LAMP
shell and automatically generates a pyATS Blitz ‘execute’ action snippet.
Basic usage
Exec-prompt mode
Invoke execute to switch to exec-prompt mode, which behaves
like the exec prompt on a device console. Commands can be run in this mode
as if at the device exec prompt. Type ‘lamp’ to exit exec-prompt mode
and return back to LAMP shell prompt.
Example:
(lamp-leaf2) execute
leaf2#
leaf2# show ip route
2024-08-06 20:44:28,066: %UNICON-INFO: +++ leaf2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/3] via 20.1.1.1, 04:45:25, GigabitEthernet1/0/1
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/2] via 20.1.1.1, 3d04h, GigabitEthernet1/0/1
10.0.0.0/24 is subnetted, 1 subnets
O 10.10.10.0 [110/2] via 20.1.1.1, 3d04h, GigabitEthernet1/0/1
20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 20.1.1.0/24 is directly connected, GigabitEthernet1/0/1
L 20.1.1.2/32 is directly connected, GigabitEthernet1/0/1
leaf2#
leaf2# terminal width 0
2024-08-06 20:44:28,066: %UNICON-INFO: +++ leaf2 with via 'a': executing command 'terminal width 0' +++
terminal width 0
leaf2#
leaf2# lamp
(lamp-leaf2)
After exiting, LAMP generates a Blitz ‘execute’ action snippet with all commands run in this mode:
(lamp-leaf2) list 1
execute:
device: leaf2
command: |-
show ip route
terminal width 0
(lamp-leaf2)
Direct command execution
Commands can also be run directly by providing them as arguments to execute.
The output of the command execution on the device console always gets printed
on the terminal screen.
Example:
(lamp-host2) execute show ip route
2024-07-26 15:40:42: %LAMP-INFO: +..............................................................................+
2024-07-26 15:40:42: %LAMP-INFO: : Execute 'show ip route' on 'host2' :
2024-07-26 15:40:42: %LAMP-INFO: +..............................................................................+
2024-07-26 15:40:42,819: %UNICON-INFO: +++ host2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
host2#
(lamp-host2)
The Blitz ‘execute’ action snippet is automatically generated by LAMP as shown below:
(lamp-host2) list 1
execute:
device: host2
command: show ip route
(lamp-host2)
Include entries
An include entry checks if a specific regex pattern matches the
output of an execute command.
To add an include entry, use execute -i <CMD>. This prompts for the
include entries after the command output is printed on the terminal.
Example:
(lamp-host2) execute -i show ip route
2024-07-26 15:45:11: %LAMP-INFO: +..............................................................................+
2024-07-26 15:45:11: %LAMP-INFO: : Execute 'show ip route' on 'host2' :
2024-07-26 15:45:11: %LAMP-INFO: +..............................................................................+
2024-07-26 15:45:11,402: %UNICON-INFO: +++ host2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
host2#
2024-07-26 15:45:11: %LAMP-INFO: +..............................................................................+
2024-07-26 15:45:11: %LAMP-INFO: : INCLUDE :
2024-07-26 15:45:11: %LAMP-INFO: +..............................................................................+
Enter pattern to INCLUDE (Press enter for multiple patterns): C\s+1.1.1.1 is directly connected, Loopback0
(lamp-host2)
LAMP autogenerates Blitz ‘execute’ action snippet with all the added include entries as a list under Blitz ‘include’ key as shown below:
(lamp-host2) list 1
execute:
device: host2
command: show ip route
include:
- C\s+1.1.1.1 is directly connected, Loopback0
(lamp-host2)
Multiple include entries can be added to verify more than one regex pattern.
Example:
(lamp-host2) execute -i show ip route
2024-07-26 17:38:07: %LAMP-INFO: +..............................................................................+
2024-07-26 17:38:07: %LAMP-INFO: : Execute 'show ip route' on 'host2' :
2024-07-26 17:38:07: %LAMP-INFO: +..............................................................................+
2024-07-26 17:38:07,900: %UNICON-INFO: +++ host2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback1
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback2
host2#
2024-07-26 17:38:08: %LAMP-INFO: +..............................................................................+
2024-07-26 17:38:08: %LAMP-INFO: : INCLUDE :
2024-07-26 17:38:08: %LAMP-INFO: +..............................................................................+
Enter pattern to INCLUDE (Press enter for multiple patterns):
(INCLUDE)> C\s+1.1.1.1 is directly connected, Loopback0
(INCLUDE)> C\s+2.2.2.2 is directly connected, Loopback1
(INCLUDE)> C\s+3.3.3.3 is directly connected, Loopback2
(INCLUDE)>
(lamp-host2)
The corresponding autogenerated snippet for the above execute command would
consist of multiple entries in ‘include’ field as shown below:
(lamp-host2) list 1
execute:
device: host2
command: show ip route
include:
- C\s+1.1.1.1 is directly connected, Loopback0
- C\s+2.2.2.2 is directly connected, Loopback1
- C\s+3.3.3.3 is directly connected, Loopback2
(lamp-host2)
If a regex pattern entry does not match the command output, LAMP reports an error and prompts the user for whether the pattern should still be added as an include entry.
Example highlighting this behaviour:
(lamp-host2) execute -i show ip route
2024-07-26 17:40:36: %LAMP-INFO: +..............................................................................+
2024-07-26 17:40:36: %LAMP-INFO: : Execute 'show ip route' on 'host2' :
2024-07-26 17:40:36: %LAMP-INFO: +..............................................................................+
2024-07-26 17:40:36,258: %UNICON-INFO: +++ host2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback1
host2#
2024-07-26 17:40:36: %LAMP-INFO: +..............................................................................+
2024-07-26 17:40:36: %LAMP-INFO: : INCLUDE :
2024-07-26 17:40:36: %LAMP-INFO: +..............................................................................+
Enter pattern to INCLUDE (Press enter for multiple patterns): C\s+3.3.3.3 is directly connected, Loopback2
Adding this entry would cause this blitz action to fail
Do you still want to add this pattern (y/n): n
Enter pattern to INCLUDE (Press enter for multiple patterns):
Exclude entries
An exclude entry checks if a specific regex pattern does NOT match the
output of an execute command.
To add an exclude entry, use execute -e <CMD>. This prompts for the
exclude entries after the command output is printed on the terminal.
Example:
(lamp-host2) execute -e show ip route
2024-07-26 17:48:51: %LAMP-INFO: +..............................................................................+
2024-07-26 17:48:51: %LAMP-INFO: : Execute 'show ip route' on 'host2' :
2024-07-26 17:48:51: %LAMP-INFO: +..............................................................................+
2024-07-26 17:48:51,924: %UNICON-INFO: +++ host2 with via 'a': executing command 'show ip route' +++
show ip 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, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
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
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback1
host2#
2024-07-26 17:48:52: %LAMP-INFO: +..............................................................................+
2024-07-26 17:48:52: %LAMP-INFO: : EXCLUDE :
2024-07-26 17:48:52: %LAMP-INFO: +..............................................................................+
Enter pattern to EXCLUDE (Press enter for multiple patterns): C\s+1.1.1.1 is directly connected, Loopback0
(lamp-host2)
LAMP autogenerates Blitz ‘execute’ action snippet with all the added exclude entries as a list under Blitz ‘exclude’ key as shown below:
(lamp-host2) list 1
execute:
device: host2
command: show ip route
exclude:
- C\s+1.1.1.1 is directly connected, Loopback0
(lamp-host2)
Multiple exclude entries can be added to verify more than one regex pattern in the same way as include entries.