Retrieve Detailed Inventory of all Devices
Scenario Overview
This guide shows how network administrators can retrieve detailed device inventory from the CNC server, including configurations, statuses, and metadata for management or troubleshooting.
Prerequisites
Before running this example, obtain an access token from 'Getting Started,' configure cnc-api-common.sh
, and ensure input/output directories exist.
Retrieve Detailed Inventory of all the Devices
To retrieve a detailed inventory of devices, run the deep_inventory_query.sh
script from the example directory. Ensure the script sets up its dependencies properly before execution.
cd cnc-inventory-api-examples;./deep_inventory_query.sh
Script Details
#!/bin/bash
. ./cnc-api-common.sh
deep_inventory_query() {
# Assuming the CNC JWT has already been obtained by running the get-cnc-jwt.sh script.
# Read from JWT file and export it as AUTH_TOKEN_HDR
export_jwt
# STEP 1 : Retrieve detailed inventory of devices within the specified range.
CNC_API_URL=$CNC_INVENTORY_API_CTX/deepinventory/query
CNC_API_OUTPUT="$PRJ/output/deep_inventory_output.json"
HEADER="range:0-99" #Specifies the range of devices to query. Update this as needed to retrieve additional devices.
http_get $CNC_API_URL $CNC_API_OUTPUT $HEADER
}
deep_inventory_query