Create and Tear Down L2VPN EVPN-VPWS Services over RSVP-TE Tunnels

This example scenario demonstrates the step-by-step invocation of Northbound (NB) APIs required to create an L2VPN service with associated RSVP-TE tunnels.

This example uses the operations from the following API references.

Prerequisites

Before running the examples, ensure that the following prerequisites are met:

  1. Day-0 device configuration is completed on all devices.
  2. Device topology is set up correctly in the CNC cluster.
  3. 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 L2VPN Service with RSVP-TE Tunnel

Run the create-l2vpn-with-rsvp-te-tunnel.sh script from the example directory to automate L2VPN service creation with RSVP-TE tunnels.

cd ~/cnc-api-examples/l2vpn-with-rsvp-te-tunnel;./create-l2vpn-with-rsvp-te-tunnel.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/l2vpn-with-rsvp-te-tunnel/input

  • RSVP-TE Tunnels
    • rsvp-te-tunnel-pe-a.json
    • rsvp-te-tunnel-pe-b.json
  • L2VPN Service
    • l2vpn-with-rsvp-te-tunnel.json

Output

The script generates the following output files in the output directory during and after execution: ~/cnc-api-examples/l2vpn-with-rsvp-te-tunnel/output

  • RSVP-TE Tunnels
    • rsvp-te-tunnel-pe-a-create-ouput.json
    • rsvp-te-tunnel-pe-b-create-ouput.json
  • L2VPN Service
    • l2vpn-with-rsvp-te-tunnel-create-ouput.json

Script Details : create-l2vpn-with-rsvp-te-tunnel.sh

#!/bin/bash
#
# Usecase:
# This example scenario demonstrates step-by-step NB API invocation with the required input 
# to create a l2vpn service with associated RSVP-TE tunnels.

export PRJ=$(cd `dirname $0`; pwd)
. $PRJ/../common-scripts/env
. $PRJ/../common-scripts/cnc-api-common.sh 

# Creates L2VPN services along with the associated RSVP-TE tunnels
create-l2vpn-with-rsvp-te-tunnel() {
    # STEP 1   :  create rsvp-te tunnel service on PE devices pe-a and pe-c
    # STEP 2   :  create l2vpn service "l2vpn-with-rsvp-te-tunnel" that use the rsvp-te tunnel services as underlay transport
  
    # STEP 1.1:  create rsvp-te tunnel service "rsvp-te-tunnel-pe-a-1110" 
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-te:te/tunnels
    CNC_API_INPUT="$PRJ/input/rsvp-te-tunnel-pe-a.json"
    CNC_API_OUTPUT="$PRJ/output/rsvp-te-tunnel-pe-a-create-output.json"
    http_post $CNC_API_URL $CNC_API_INPUT $CNC_API_OUTPUT

    # STEP 1.2:  create rsvp-te tunnel service "rsvp-te-tunnel-pe-b-1110" 
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-te:te/tunnels
    CNC_API_INPUT="$PRJ/input/rsvp-te-tunnel-pe-b.json"
    CNC_API_OUTPUT="$PRJ/output/rsvp-te-tunnel-pe-b-create-output.json"
    http_post $CNC_API_URL $CNC_API_INPUT $CNC_API_OUTPUT

    # STEP 2: create l2vpn service "l2vpn-with-rsvp-te-tunnel" that use the rsvp-te tunnel services as underlay transport
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-l2vpn-ntw:l2vpn-ntw/vpn-services
    CNC_API_INPUT="$PRJ/input/l2vpn-with-rsvp-te-tunnel.json"
    CNC_API_OUTPUT="$PRJ/output/l2vpn-with-rsvp-te-tunnel-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
    # creates l2vpn serivces along with the associated rsvp te tunnels
    create-l2vpn-with-rsvp-te-tunnel

}

main

Remove an L2VPN Sevice with RSVP-TE Tunnel

To remove the L2VPN service along with its associated RSVP-TE tunnel, run the following script:

cd ~/cnc-api-examples/l2vpn-with-rsvp-te-tunnel;./teardown-l2vpn-with-rsvp-te-tunnel.sh

The script execution outputs the API execution and results to standard output and store the results in multiple files in output folder.

Output

The script creates the following output files in the output directory during and after execution: ~/cnc-api-examples/l2vpn-with-rsvp-te-tunnel/output

  • RSVP-TE Tunnel
    • rsvp-te-tunnel-pe-a-delete-output.json
    • rsvp-te-tunnel-pe-b-delete-output.json
  • L2VPN Service
    • l2vpn-with-rsvp-te-tunnel-delete-output.json

Script Details : teardown-l2vpn-with-rsvp-te-tunnel.sh

#!/bin/bash
#
# Removed the services and resources created in the L2VPN with RSVP-TE tunnels usecase

export PRJ=$(cd `dirname $0`; pwd)
. $PRJ/../common-scripts/env
. $PRJ/../common-scripts/cnc-api-common.sh

# Deletes L2VPN service and its associated RSVP-TE tunnels
teardown-l2vpn-with-rsvp-te-tunnel() {
    # SETP 1:  Delete the L2VPN service  
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-l2vpn-ntw:l2vpn-ntw/vpn-services/vpn-service=l2vpn-with-rsvp-te-tunnel
    CNC_API_OUTPUT="$PRJ/output/l2vpn-with-rsvp-te-tunnel-delete-output.json"
    http_delete $CNC_API_URL $CNC_API_OUTPUT

    # SETP 2.1:  Delete RSVP-TE tunnel "rsvp-te-tunnel-pe-b-1110" 
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-te:te/tunnels/tunnel=rsvp-te-tunnel-pe-b-1110
    CNC_API_OUTPUT="$PRJ/output/rsvp-te-tunnel-pe-b-delete-output.json"
    http_delete $CNC_API_URL $CNC_API_OUTPUT

    # SETP 2.2:  Delete RSVP-TE tunnel "rsvp-te-tunnel-pe-a-1110" 
    CNC_API_URL=$CNC_NSO_RESTCONF_CTX/data/ietf-te:te/tunnels/tunnel=rsvp-te-tunnel-pe-a-1110
    CNC_API_OUTPUT="$PRJ/output/rsvp-te-tunnel-pe-a-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 the l2vpn service and associated rsvp-te tunnels
    teardown-l2vpn-with-rsvp-te-tunnel

}

main