Add a Serial Number or an Ownership Voucher
Scenario Overview
This use-case demonstrates how to add the following:
- A Serial Number (SN)
- An Ownership Voucher (OV) using a .vcj file
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 Serial Number (SN)
1. Add the below content to a file named 'add_serialnumbers.sh'.
#!/bin/bash
. ./setup.sh
SN_ADD_URL=/serialnumber
API_URL=$ZTP_URL$SN_ADD_URL
DATA='{
"data": [
{
"serialNumber":"SampleSN"
}
]
}'
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_serialnumbers.sh' file using the below command.
chmod 755 add_serialnumbers.sh
3. Execute 'add_serialnumbers.sh' script to add a Serial Number 'SampleSN' to CNC.
./add_serialnumbers.sh
'SampleSN' would be added as a SN in CNC. A successful sample execution of the script is shown below.
$ ./add_serialnumbers.sh
{
"code": 201,
"message": "Created Successfully",
"processedRecordCount": 1
}
Add an Ownership Voucher (OV)
1. Add the below content to a file named 'add_ownership_voucher.sh'.
#!/bin/bash
. ./setup.sh
OV_ADD_URL=/ovs/import
API_URL=$ZTP_URL$OV_ADD_URL
DATA='{
"isOverwrite":"false",
"fileName":"SampleOV.vcj",
"b64Content":"Q2lzY29Pd25lcnNoaXBWb3VjaGVyQ29udGVudA=="
}'
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_ownership_voucher.sh' file using the below command.
chmod 755 add_ownership_voucher.sh
3. Execute 'add_ownership_voucher.sh' script to add a Serial Number 'SampleSN' to CNC.
./add_ownership_voucher.sh
'SampleVoucher' would be added as a SN in CNC. A successful sample execution of the script is shown below.
$ ./add_ownership_voucher.sh
{
"code": 200,
"message": "Ownership voucher successfully added",
"processedRecordCount": 1
}