Debian Codegraph @

docs/cli/debug.md

raw symbols SCIP
1 ---
2 title: ANTA debug commands
3 hide:
4 - tags
5 tags:
6 - CLI
7 - Troubleshooting
8 ---
9
10 <!--
11 ~ Copyright (c) 2023-2026 Arista Networks, Inc.
12 ~ Use of this source code is governed by the Apache License 2.0
13 ~ that can be found in the LICENSE file.
14 -->
15
16 The ANTA CLI includes a set of debugging tools, making it easier to build and test ANTA content. This functionality is accessed via the `debug` subcommand and offers the following options:
17
18 - Executing a command on a device from your inventory and retrieving the result.
19 - Running a templated command on a device from your inventory and retrieving the result.
20
21 These tools are especially helpful in building the tests, as they give a visual access to the output received from the eAPI. They also facilitate the extraction of output content for use in unit tests, as described in our [contribution guide](../contribution.md).
22
23 !!! warning
24 The `debug` tools require a device from your inventory. Thus, you must use a valid [ANTA Inventory](../usage-inventory-catalog.md#device-inventory).
25
26 ## DEBUG command overview
27
28 ```bash
29 --8<-- "anta_debug_help.txt"
30 ```
31
32 ## Executing an EOS command
33
34 You can use the `run-cmd` entrypoint to run a command, which includes the following options:
35
36 ### Command overview
37
38 ```bash
39 --8<-- "anta_debug_runcmd_help.txt"
40 ```
41
42 !!! tip
43 `username`, `password`, `enable-password`, `enable`, `timeout` and `insecure` values are the same for all devices
44
45 ### Example
46
47 This example illustrates how to run the `show interfaces description` command with a `JSON` format (default):
48
49 ```bash
50 anta debug run-cmd --command "show interfaces description" --device DC1-SPINE1
51 Run command show interfaces description on DC1-SPINE1
52 {
53 'interfaceDescriptions': {
54 'Ethernet1': {'lineProtocolStatus': 'up', 'description': 'P2P_LINK_TO_DC1-LEAF1A_Ethernet1', 'interfaceStatus': 'up'},
55 'Ethernet2': {'lineProtocolStatus': 'up', 'description': 'P2P_LINK_TO_DC1-LEAF1B_Ethernet1', 'interfaceStatus': 'up'},
56 'Ethernet3': {'lineProtocolStatus': 'up', 'description': 'P2P_LINK_TO_DC1-BL1_Ethernet1', 'interfaceStatus': 'up'},
57 'Ethernet4': {'lineProtocolStatus': 'up', 'description': 'P2P_LINK_TO_DC1-BL2_Ethernet1', 'interfaceStatus': 'up'},
58 'Loopback0': {'lineProtocolStatus': 'up', 'description': 'EVPN_Overlay_Peering', 'interfaceStatus': 'up'},
59 'Management0': {'lineProtocolStatus': 'up', 'description': 'oob_management', 'interfaceStatus': 'up'}
60 }
61 }
62 ```
63
64 ## Executing an EOS command using templates
65
66 The `run-template` entrypoint allows the user to provide an [`f-string`](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python) templated command. It is followed by a list of arguments (key-value pairs) that build a dictionary used as template parameters.
67
68 ### Command overview
69
70 ```bash
71 --8<-- "anta_debug_runtemplate_help.txt"
72 ```
73
74 > `username`, `password`, `enable-password`, `enable`, `timeout` and `insecure` values are the same for all devices
75
76 ### Example
77
78 This example uses the `show vlan {vlan_id}` command in a `JSON` format:
79
80 ```bash
81 anta debug run-template --template "show vlan {vlan_id}" vlan_id 10 --device DC1-LEAF1A
82 Run templated command 'show vlan {vlan_id}' with {'vlan_id': '10'} on DC1-LEAF1A
83 {
84 'vlans': {
85 '10': {
86 'name': 'VRFPROD_VLAN10',
87 'dynamic': False,
88 'status': 'active',
89 'interfaces': {
90 'Cpu': {'privatePromoted': False, 'blocked': None},
91 'Port-Channel11': {'privatePromoted': False, 'blocked': None},
92 'Vxlan1': {'privatePromoted': False, 'blocked': None}
93 }
94 }
95 },
96 'sourceDetail': ''
97 }
98 ```
99
100 ### Example of multiple arguments
101
102 !!! warning
103 If multiple arguments of the same key are provided, only the last argument value will be kept in the template parameters.
104
105 ```bash
106 anta -l DEBUG --log-file anta.log debug run-template --template "ping {dst} source {src}" dst "8.8.8.8" src Loopback0 --device DC1-SPINE1
107 > {'dst': '8.8.8.8', 'src': 'Loopback0'}
108
109 anta -l DEBUG --log-file anta.log debug run-template --template "ping {dst} source {src}" dst "8.8.8.8" src Loopback0 dst "1.1.1.1" src Loopback1 --device DC1-SPINE1
110 > {'dst': '1.1.1.1', 'src': 'Loopback1'}
111 # Notice how `src` and `dst` keep only the latest value
112 ```