Creation of Configuration Template
Scenario Overview
This guide demonstrates how to create user-defined configuration templates using the CNC Device Configuration Templates API. Configuration templates allow network administrators to standardize and automate the deployment of configuration commands across multiple devices, improving operational efficiency and reducing errors.
The operation in the following API references is used in this example.
Prerequisites
Before running this example, ensure:
- You have obtained an access token. Refer to the 'Getting Started' section for instructions.
- The
cnc-api-common.sh
script is properly configured. - Necessary input and output directories exist for storing and retrieving configuration template files.
Creation of Configuration Template
Run the device-config-template-creation.sh
script from the example directory to create a new configuration template.
cd cnc-device-config-templates-api-examples;./device-config-template-creation.sh
Script Details
This script reads input from the device-config-template-creation.json file located in the input directory. Upon successful execution of template creation, a new template will show under the config templates page and the output is saved to the device-config-template-creation.json file in the output directory.
For the request payload, user needs to provide the specified fields in the json payload below:
#!/bin/bash
. ./cnc-api-common.sh
device-config-template-creation() {
# Assume 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 : Create Device Configuration Template
# STEP 2 : Store the output in CNC_API_OUTPUT file
CNC_API_URL=$CNC_DEVICE_CONFIG_API_CTX/v1/templates
CNC_API_INPUT="$PRJ/input/device-config-template-creation.json"
CNC_API_OUTPUT="$PRJ/output/device-config-template-creation.json"
http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
}
device-config-template-creation