L3VPN with ODN: Service Creation and Removal
This example shows step-by-step NB API calls to create an L3VPN service and bind it to ODN using routing policies and resource configurations.
This example uses the operations from the following API references.
- L3VPN Provisioning API: This API provisions L3VPN services.
- SR-TE ODN Provisioning API: This API provisions SR-TE ODN templates and related configurations.
Prerequisites
Before running the examples, ensure that the following prerequisites are met:
- Complete the Day-0 device configuration on all devices.
- Set up the device topology correctly in the CNC cluster.
- If your topology or data differs from the example input, adjust the input data accordingly. Refer to the CNC installation guide and administration guide for details on configuring day-0 devices and topology.
Create L3VPN with ODN
Run the script create-l3vpn-with-odn.sh
from the example directory to create an L3VPN service along with its associated ODN template service and routing policy resources, including the policy definition and color tagset.
cd ~/cnc-api-examples/l3vpn-with-odn;./create-l3vpn-with-odn.sh
The script execution outputs the API execution and results to standard output and store the results in multiple files in output folder.
Input
The script requires the following input files from the input directory: ~/cnc-api-examples/l3vpn-with-odn/input
- ODN Template
- odn-90.json
- Route Policy Resources
- routing-policy-90.json
- L3VPN Service
- l3vpn-with-odn-90.json
Output
During and after the execution of the script, the following output files are available in output directory: ~/cnc-api-examples/l3vpn-with-odn/output
- ODN Template
- odn-90-create-ouput.json
- Route Policy Resources
- routing-policy-90-create-ouput.json
- L3VPN Service
- l3vpn-with-odn-90-create-ouput.json
Script Details: create-l3vpn-with-odn.sh
#!/bin/bash
#
# Usecase:
# This example scenario demonstrates step by step NB API invocation with the required input
# to create an L3VPN service and associated underlay transport by binding the l3vpn service
# to ODN using the routing policy and associated resources configuration.
export PRJ=$(cd `dirname $0`; pwd)
. $PRJ/../common-scripts/env
. $PRJ/../common-scripts/cnc-api-common.sh
# creates l3vpn service along with the associated odn service and routing policy resources
create-l3vpn-with-odn() {
# STEP 1 : Create ODN template service "odn-90" for 3 PE devices with color 90
# STEP 2 : create routing policy resourcess that include the color tagset "COLOR_90"
# and policy definition "policy-definition-90" that use the color tagset
# STEP 3 : create l3vpn service "l3vpn-with-odn-90" with 3 vpn-nodes configured to use
# the route policy resource created above as a export policy in each vpn-nodes
# STEP 1: Create odn-template service "odn-90"
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/cisco-sr-te-cfp:sr-te/cisco-sr-te-cfp-sr-odn:odn
CNC_API_INPUT="$PRJ/input/odn-90.json"
CNC_API_OUTPUT="$PRJ/output/odn-90-create-output.json"
http_post $CNC_API_URL $CNC_API_INPUT $CNC_API_OUTPUT
# STEP 2: Create routing policy resources
# color tagset "COLOR_90" and policy definition "policy-definition-90"
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data
CNC_API_INPUT="$PRJ/input/routing-policy-90.json"
CNC_API_OUTPUT="$PRJ/output/routing-policy-90-create-output.json"
http_patch $CNC_API_URL $CNC_API_INPUT $CNC_API_OUTPUT
# STEP 3: Create l3vpn service "l3vpn-with-odn-90"
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-l3vpn-ntw:l3vpn-ntw/vpn-services
CNC_API_INPUT="$PRJ/input/l3vpn-with-odn-90.json"
CNC_API_OUTPUT="$PRJ/output/l3vpn-with-odn-90-create-output.json"
http_post $CNC_API_URL $CNC_API_INPUT $CNC_API_OUTPUT
}
main() {
# assume cnc jwt is obtained prior to invoking this method by executing get-cnc-jwt.sh script
# read from jwt file and export it as AUTH_TOKEN_HDR
export_jwt
# create l3vpn service along with the associated odn service and routing policy resources
create-l3vpn-with-odn
}
main
Remove L3VPN with ODN
To remove the L3VPN service along with its associated ODN template service and routing policy resources, run the following script:
cd ~/cnc-api-examples/l3vpn-with-odn;./teardown-l3vpn-with-odn.sh
The script execution outputs the API execution and results to standard output and store the results in multiple files in output folder.
Output
During and after the execution of the script, the following output files are available in output directory: ~/cnc-api-examples/l3vpn-with-odn/output
- Route Policy Resources
- policy-definition-90-delete-output.json
- tag-set-90-delete-output.json
- ODN Template
- odn-90-delete-output.json
- L3VPN Service
- l3vpn-with-odn-90-delete-output.json
Script Details: teardown-l3vpn-with-odn.sh
#!/bin/bash
#
# removes the l3vpn services and associated odn and routing policy resources created for the usecase.
export PRJ=$(cd `dirname $0`; pwd)
. $PRJ/../common-scripts/env
. $PRJ/../common-scripts/cnc-api-common.sh
# deletes l3vpn service along with the associated odn service and route policy resources
teardown-l3vpn-with-odn() {
# STEP 1 : delete l3vpn service
# STEP 2 : delete routing policy - color tag and policy definition
# STEP 3 : delete odn
# SETP 1: Delete L3VPN service
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-l3vpn-ntw:l3vpn-ntw/vpn-services/vpn-service=l3vpn-with-odn-90
CNC_API_OUTPUT="$PRJ/output/l3vpn-with-odn-90-delete-output.json"
http_delete $CNC_API_URL $CNC_API_OUTPUT
# SETP 2.1: Delete routing policy - policy definition "policy-definition-90"
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/cisco-l3vpn-routing-policy:l3vpn-routing-policy/policy-definitions/policy-definition=policy-definition-90
CNC_API_OUTPUT="$PRJ/output/policy-definition-90-delete-output.json"
http_delete $CNC_API_URL $CNC_API_OUTPUT
# SETP 2.2: Delete routing policy - color tagset "COLOR_90
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/cisco-l3vpn-routing-policy:l3vpn-routing-policy/defined-sets/tag-sets/tag-set=COLOR_90
CNC_API_OUTPUT="$PRJ/output/tag-set-90-delete-output.json"
http_delete $CNC_API_URL $CNC_API_OUTPUT
# SETP 3: Delete odn-template service "odn-90"
CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/cisco-sr-te-cfp:sr-te/cisco-sr-te-cfp-sr-odn:odn/odn-template=odn-90
CNC_API_OUTPUT="$PRJ/output/odn-90-delete-output.json"
http_delete $CNC_API_URL $CNC_API_OUTPUT
}
main() {
# Assume CNC JWT has been obtained prior to invoking this method by executing get-cnc-jwt.sh script
# Read from JWT file and export it as AUTH_TOKEN_HDR
export_jwt
# Delete l3vpn service along with the associated ODN service and route policy resources
teardown-l3vpn-with-odn
}
main