Sample Code

This page lists sample code for a few common use cases. While samples are provided in Python language, functionality can be ported in any language.

Creating Lightning ADC Cluster

Lightning ADC cluster may be of type Auto or Manual. The code here demonstrates how to create a cluster of type Manual. The cluster ID returned at the end of script is the unique ID of the cluster. This is to be supplied to the Lightning ADC instance. When Lightning ADC connects to the Harmony Controller, it identifies the cluster which the instance belongs to, and places accordingly.

Creating an Application

For creating an application configuration, the entire object hierarchy needs to be created. Calling POST APIs of the objects in the sequence does the job. By default, all the values are taken as default. Only required items are name of the application and first domain for which the application is being created. However, for application to work properly and handle traffic, a few more things like Server IP addresses and Lightning ADC Cluster is also required.

The code example here assumes that required data is available in a JSON file (app_params.json) and makes following calls in sequence:

  1. Create Session
  2. Create Application
  3. Create Domain EndPoint
  4. Create Service EndPoint
  5. Create Smart Flow
  6. Create Smart Flow Policies
  7. Associate Application to a Lightning ADC Cluster

Tear Down

Tear down here refers to deleting application and Lightning ADC cluster. Before a cluster can be deleted, it should be removed from all applications. Also all the ADC instances should be removed from the cluster. So the steps for tear down are as following:

  1. Delete application
  2. Read all ADC instances in the cluster and delete them - the instances should be shut down manually before performing this
  3. Delete Cluster