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

Latest commit

 

History

History
61 lines (42 loc) · 1.93 KB

File metadata and controls

61 lines (42 loc) · 1.93 KB

Table of contents

Get the CVP version

curl -k -X GET --header 'Accept: application/json' -b access_token=`cat token.tok` 'https://192.168.0.5/cvpservice/cvpInfo/getCvpInfo.do'

Get the CVP inventory

Getting the token from a local file

curl -k -X GET --header 'Accept: application/json' -b access_token=`cat token.tok` 'https://192.168.0.5/cvpservice/inventory/devices'

Getting the token from an environment variable

Copy the token in an environment variable

token=xxx

Read the environment variable

echo $token

Use the environment variable from cURL

curl -k -X GET --header 'Accept: application/json' --cookie "access_token=$token" 'https://192.168.0.5/cvpservice/inventory/devices'

Install jq to parse JSON in bash

sudo apt-get install -y jq

Filter the output to see only the first device of the inventory

curl -k -s -X GET --header 'Accept: application/json' -b access_token=`cat token.tok` 'https://192.168.0.5/cvpservice/inventory/devices' | jq '.[0]'

Filter the output to see only the hostname of each device of the inventory

curl -k -s -X GET --header 'Accept: application/json' -b access_token=`cat token.tok` 'https://192.168.0.5/cvpservice/inventory/devices' | jq '.[].hostname'