The CN-WAN Adaptor is part of the Cloud Native SD-WAN (CN-WAN) project. Please check the CN-WAN documentation for the general project overview and architecture. You can contact the CN-WAN team at cnwan@cisco.com.
This CN-WAN Adaptor takes as input several cloud parameters, such as endpoint IP and port, and associated metadata (e.g. traffic profiles), and sends them to a SD-WAN controller. The SD-WAN controller implements policies to steer traffic flows for these endpoints to the desired tunnel or apply a SLA on them. On its current iteration the CN-WAN Adaptor supports Viptela vManage as SD-WAN controller. The Adaptor needs valid credentials to connect to the API of the SD-WAN controller (user, password, and IP or domain name).
To see all the possible Adaptor API calls, run the Adaptor as a Docker container (see below) and type http://localhost:80/ui/ in your browser (if exposing the Adaptor though a port other than 80 via Docker, use the appropiate port instead). In addition, the file CN-WAN Adaptor.postman_collection.json contains a Postman collection with examples of all the API functions. In particular, the Adaptor provides the /cnwan/events
API endpoint http://localhost:80/cnwan/events for the CN-WAN Reader to send events.
The adaptor runs in a Docker container:
# build the image docker build -t cnwan_adaptor . # starting up a container docker run -p 80:8080 cnwan_adaptor
It is possible to specify the SD-WAN controller credentials through environment variables (instead of via the Adaptor API):
docker run -p 80:8080 \ -e SDWAN_IP=sample.server.com \ -e SDWAN_USERNAME=user \ -e SDWAN_PASSWORD=xxxxx \ -e MERGE_POLICY=merge_policy_name \ cnwan_adaptor
If you want a minimal working setup, equivalent to the one used in the CN-WAN demo presented at KubeCon EU 2020, the script examples/setup_kubecon_demo.sh sets everything up a for you in the adaptor and your SD-WAN controller. Before running it, please:
jq
The adaptor supports both vManage Application Aware Routing (e.g. for SLAs) and Traffic Data (e.g. to send traffic to a specific tunnel color) policies.
The adaptor requires the following configuration in vManage (the script setup_kubecon_demo.sh automates this process):
sdwanMergedPolicyName
variable in the credentials
schema (POST /credentials
). The empty policies will be used to merge all policies of each type into a single one per type.Traffic Engineering
rule with an empty match and the action Local TLOC
, specifying the desired color tunnel and encapsulation.AppRoute
rule with an empty match and the action SLA Class List
with the desired SLA class.POST /mappings
Adaptor API this way:
metadataKey
is the key used in the CN-WAN readermetadataValue
is the value used in the CN-WAN readerpolicyName
is the name of one of the policies defined in step 3policyType
is AppRoute
for an Application Aware Routing or Data
for Traffic Data policies.metadataValue
to policyName
mapping is 1:1 (two metadata values cannot share the same policyName
). On the other hand, a single metadataKey
supports any number of metadataValue
.Internally, the adaptor works this way:
Centralized Policy
and apply it to the Sites and VPNs they need.AppAware
and Traffic Data
policies as needed in the SD-WAN controller (these are merged and referenced by the Centralized Policy
).metadataValue
in Service Directory using the POST /mappings
API in the adaptormetadataValue
. Eg. an endpoint with metadataValue = video
will be added to the prefer_biz_internet
policy./events
API call supports adding, removing and updating endpoint information.PUT /mapping
at any moment, and the adaptor will move all endpoints from such mapping to the new policy and update accordingly. This feature also supports moving from TrafficData
to AppAware
, and viceversa.This adaptor was generated by the swagger-codegen project. By using the
OpenAPI-Spec from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
It is possible to use the metadata_adaptor python library without the server. It exposes several high level functions equivalent to he ones in the adaptor. To use the library:
cd adaptor_library # Generate the package python3 setup.py sdist bdist_wheel # Install the package pip3 install requests pip3 install dist/metadata_adaptor-2.0.0.tar.gz # Use the library python3 import metadata_adaptor.core_lib as sdwan api = sdwan.api_endpoint() # Example 1: configure controller credentials cred = { "user": "XXXXXX", "password": "XXXXXX", "sdwanControllerIpAddress": "sample.server.com", "sdwanMergedPolicyName" : "your_merge_policy" } api.post_credentials(cred) # Example 2: create a new mapping mapping = { 'metadataKey' : 'traffic-profile', 'metadataValue' : 'nice_name_to_remember_your_mapping', 'policyType' : 'Data', 'policyName' : 'sample_policy_in_controller' } api.post_mapping(mapping)
You can find all the library functions in core_lib.py
Owner
Contributors
Categories
Programming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community