Add Device in ZTP
Scenario Overview
This use-case demonstrates how to add a device for onboarding via ZTP.
This functionality is supported by ZTP service component of EMF (Element Management Function).
Prerequisites
Before running this example, ensure to setup the required environment. Refer 'Getting Started' section.
Add a ZTP Device
1. Add the below content to a file named 'add_device.sh'.
#!/bin/bash
. ./setup.sh
ZTP_ADD_DEVICE_URL=/device
API_URL=$ZTP_URL$ZTP_ADD_DEVICE_URL
# Custom Parameters
HOST_NAME="host1"
CRED_PROFILE="superuser"
VENDOR="Cisco Systems"
OS_PLATFORM="IOS XR"
PROFILE_NAME="test-profile"
IP_ADDR_FAMILY="IPV4"
IP_ADDR="10.10.10.10"
MASK=24
SERIAL_NUMBER="SampleSN"
DATA='{
"nodes": [
{
"uuid": "",
"hostName": "HOST_NAME",
"macAddress": "",
"inventoryId": "",
"ipAddress": {
"mask": null
},
"credentialProfile": "CRED_PROFILE",
"status": "Unprovisioned",
"secureZtpInfo": {
"postConfig": null,
"preConfig": null,
"configMode": null
},
"vendor": "VENDOR",
"osPlatform": "OS_PLATFORM",
"deviceFamily": "",
"image": "",
"config": "",
"version": "",
"productId": "",
"versionId": "",
"profileName": "PROFILE_NAME",
"configAttributes": {
"hname": "HOST_NAME"
},
"isSecureZtp": "false",
"additionalAttributes": {
"routingInfo.globalisissystemid": "",
"routingInfo.globalospfrouterid": "",
"routingInfo.ipv6routerid": "",
"routingInfo.teRouterid": ""
},
"enableOption82": "false",
"providerInfo": {
"providerName": ""
},
"connectivityDetails": [
{
"protocol": "TELNET",
"inetAddr": [
{
"inetAddressFamily": "IP_ADDR_FAMILY",
"ipaddrs": "IP_ADDR",
"mask": MASK
}
],
"port": 23,
"timeout": 30
},
{
"protocol": "SNMP",
"inetAddr": [
{
"inetAddressFamily": "IP_ADDR_FAMILY",
"ipaddrs": "IP_ADDR",
"mask": MASK
}
],
"port": 161,
"timeout": 30
}
],
"serialNumber": [
"SERIAL_NUMBER"
]
}
]
}'
HOST_NAME="host1"
CRED_PROFILE="superuser"
VENDOR="Cisco Systems"
OS_PLATFORM="IOS XR"
PROFILE_NAME="test-profile"
IP_ADDR_FAMILY="IPV4"
IP_ADDR="10.10.10.10"
MASK=24
SERIAL_NUMBER="SampleSN"
DATA=`echo "${DATA}" | sed "s/HOST_NAME/${HOST_NAME}/"`
DATA=`echo "${DATA}" | sed "s/CRED_PROFILE/${CRED_PROFILE}/"`
DATA=`echo "${DATA}" | sed "s/VENDOR/${VENDOR}/"`
DATA=`echo "${DATA}" | sed "s/OS_PLATFORM/${OS_PLATFORM}/"`
DATA=`echo "${DATA}" | sed "s/PROFILE_NAME/${PROFILE_NAME}/"`
DATA=`echo "${DATA}" | sed "s/IP_ADDR_FAMILY/${IP_ADDR_FAMILY}/"`
DATA=`echo "${DATA}" | sed "s/IP_ADDR/${IP_ADDR}/"`
DATA=`echo "${DATA}" | sed "s/MASK/${MASK}/"`
DATA=`echo "${DATA}" | sed "s/SERIAL_NUMBER/${SERIAL_NUMBER}/"`
curl $CURL_OPTS -X POST -H "Authorization: Bearer ${BEARER_TOKEN}" -H "Content-Type: application/json" -d "${DATA}" $API_URL | jq .
2. Set execute permissions for 'add_device.sh' file using the below command.
chmod 755 add_device.sh
3. Execute 'add_device.sh' script.
./add_device.sh
This will add a device in CNC for onboarding via ZTP. Replace the values for the following request body parameters in the above file, as required.
- Host Name
- Credential Profile
- Vendor
- OS Platform
- Profile Name
- IP Address Family
- Device IP Address
- Mask
- Serial Number
Post successful execution of the above script, 'test-profile' would be added as a ZTP profile in CNC. A successful sample execution of the script is shown below.
$ ./create_ztp_profile.sh
{
"code": 201,
"message": "Device Added Successfully"
}
Post this step ZTP can be initiated from device side.