Inspect Data Structures in Transformed Lab Topology
netlab inspect prints data structures in transformed lab topology (usually stored in netlab.snapshot.yml
) created by the netlab create command. You can display data in YAML or JSON format and select a subset of data from the transformed topology or an individual node.
When selecting data from an individual node, netlab adds group variables to node data, effectively displaying what you would see in the Ansible inventory.
Note
netlab inspect command is replicating the functionality of netlab create -o yaml:expression command with a more convenient user interface.
Usage
usage: netlab inspect [-h] [--snapshot [SNAPSHOT]] [--node NODE]
[--all] [--format {yaml,json}] [expr]
Inspect data structures in transformed lab topology
positional arguments:
expr Data selection expression
options:
-h, --help show this help message and exit
--snapshot [SNAPSHOT]
Transformed topology snapshot file
--node NODE Display data for selected node(s)
--all Add global Ansible variables to node data
--format {yaml,json} Select data presentation format
Topology Inspection Examples
To display this information… |
…use this command |
---|---|
whole transformed topology |
|
node data |
|
address pools |
|
You can inspect any subset of the lab topology, for example:
To display this information… |
…use this command |
---|---|
device data for device |
|
valid attributes for the BGP module |
|
Finally, the data selection argument is evaluated as a Python expression, so you can display most things that can be expressed as a one-line expression (don’t forget to quote the expression):
To display this information… |
…use this command |
---|---|
node names |
|
Node Inspection Examples
You can use the --node
parameter to inspect the data structure of a single node, a list of nodes (separated by commas), or a wildcard expression.
To display this information… |
…use this command |
---|---|
data for node |
|
interface data for node |
|
first interface on node |
|
BGP parameters on R1 and R2 |
|
VRFs on all nodes |
|
Warning
You can use Python expressions only when specifying a single node to inspect.
Node data includes Ansible group variables, for example:
$ netlab inspect --node r1
af:
ipv4: true
ansible_connection: network_cli
ansible_host: 192.168.121.101
ansible_network_os: eos
ansible_ssh_pass: vagrant
ansible_user: vagrant
box: arista/veos
...
Tip
Use the --all
option if you want to display the global variables available in Ansible playbooks (address pools, paths, named prefixes)
Data from multiple nodes is shown in a tabular format, for example:
$ netlab inspect --node r1,r2 loopback
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ r1 ┃ r2 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ ifindex: 0 │ ifindex: 0 │
│ ifname: Loopback0 │ ifname: Loopback0 │
│ ipv4: 10.0.0.1/32 │ ipv4: 10.0.0.2/32 │
│ neighbors: [] │ neighbors: [] │
│ type: loopback │ type: loopback │
│ virtual_interface: true │ virtual_interface: true │
└─────────────────────────┴─────────────────────────┘