Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Latest commit

 

History

History
163 lines (114 loc) · 9.11 KB

File metadata and controls

163 lines (114 loc) · 9.11 KB

Table of contents

cURL options

Disable URL globbing

By default cURL uses URL globbing. The globbing uses the reserved symbols [] and {} that normally cannot be part of a legal URL. If the URLs contain these symbols, disable URL globbing from cURL using the -g option.

Ignore the warning about the certificates

Ignore the warning about the certificates with the -k option.

Get CVP inventory

Get the device-id YANG leaf for all the devices from CVP inventory

curl -s -k -X GET --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5:443/restconf/data/inventory/state/device/device-id?arista-origin=arista&arista-target='

Get OpenConfig data streamed by EOS devices and stored in CVP

Go to Devices > Inventory and replace the target in the commands below with the device ID found in the CVP device inventory.
The device ID is the device SN.

BGP

Get the state YANG container for all the bgp neighbors

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/state?arista-target=spine1&arista-origin=openconfig'

Get the session-state YANG leaf for all the bgp neighbors

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/state/session-state?arista-target=spine1&arista-origin=openconfig'

Get the config YANG container for all the bgp neighbors

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/config?arista-target=spine1&arista-origin=openconfig'

Get the config YANG container for the bgp neighbor 172.16.200.1

curl -s -g -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.200.1]/config?arista-target=spine1&arista-origin=openconfig'

Get the state YANG container for the bgp neighbor 172.16.200.1

curl -s -g -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.200.1]/state?arista-target=spine1&arista-origin=openconfig'

Get the session-state YANG leaf for the bgp neighbor 172.16.200.1

curl -s -g -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor[neighbor-address=172.16.200.1]/state/session-state?arista-target=spine1&arista-origin=openconfig'

Interfaces

Get the state YANG container for all the interfaces

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface/state?arista-target=spine1&arista-origin=openconfig'

Get the state YANG container of the interface Ethernet1

curl -s -k -g -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface[name=Ethernet1]/state?arista-target=spine1&arista-origin=openconfig'

Get the counters YANG container for all the interfaces

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface/state/counters?arista-target=spine1&arista-origin=openconfig'

Get the admin-status YANG leaf for all the interfaces

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface/state/admin-status?arista-target=spine1&arista-origin=openconfig'

Get the admin-status YANG leaf for the interface Ethernet6

curl -s -g -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface[name=Ethernet6]/state/admin-status?arista-target=spine1&arista-origin=openconfig'

Use jq to parse JSON in bash

Install jq

sudo apt-get install -y jq

Pretty prints the JSON output

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface/state?arista-target=leaf1&arista-origin=openconfig' | jq .
curl -s -k -g -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface[name=Ethernet1]?arista-target=leaf1&arista-origin=openconfig' | jq .

Filter the output to see only the interfaces name

curl -s -k -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface?arista-target=leaf1&arista-origin=openconfig' | jq .interfaces.interface[].name

Filter the output to see only the counters container of the interface ethernet 1

curl -s -k -g -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface[name=Ethernet1]?arista-target=leaf1&arista-origin=openconfig' | jq .interfaces.interface[0].state.counters

Filter the output to see only the leaf enabled of the container config of the interface ethernet 1

curl -s -k -g -X GET --header 'Accept: application/json' --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5/restconf/data/interfaces/interface[name=Ethernet1]?arista-target=leaf1&arista-origin=openconfig' | jq .interfaces.interface[0].config.enabled

Filter the output to see only the devices id

curl -s -k -X GET --header "Authorization: Bearer `cat token.tok`" 'https://192.168.0.5:443/restconf/data/inventory/state/device/device-id?arista-origin=arista&arista-target=' | jq '.inventory.state.device[]."device-id"'