Skip to content

jordipv/cnwan-adaptor-1

 
 

Repository files navigation

CNWAN Adaptor

The CNWAN Adaptor is part of the Cloud Native SD-WAN (CNWAN) project. Please check the CNWAN documentation for the general project overview and architecture. You can contact the CNWAN team at cnwan@cisco.com.

Overview

This CNWAN 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 SDWAN controller. The controller implements policies to steer traffic flows for these endpoints to the desired tunnel or apply a SLA on them.

The adaptor needs valid credentials for the SDWAN controller (user, password and IP or domain name).

To see all the possible API calls, run the adaptor and type http://localhost:80/ui/ in your browser. In addition, the file CNWAN 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 (e.g. http://localhost:80/cnwan/events) for the CNWAN Reader to send events.

Requirements

Docker Engine 19.03.8+

Usage

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 SDWAN controller credentials through environment variables:

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

SDWAN controller configuration

The adaptor makes the following assumptions regarding the controller configuration:

  1. The policyName variable in the mappings schema corresponds to a previously defined policy in the controller, containing its tunnel or SLA.
  2. The sdwanMergedPolicyName variable in the credentials schema corresponds to another traffic policy that will be used to merge all the policies into a single one, so it can be activated.
  3. The mapping of metadataValue to policyName is 1:1 (two metadata values cannot share the same policyName). On the other hand, a single metadataKey supports any number of metadataValue.

More info

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.

Using the library without the server

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)

The library functions are in adaptor_library/metadata_adaptor/core_lib.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.3%
  • Dockerfile 1.7%