How to Push a JSON-Formatted NSX-ALB (Formerly AVI) Config File to the NSX-ALB Controller

This article describes the 'how-to' push JSON formatted NSX-ALB config to NSX-ALB Controller

Preface

This article and the python script that is provided here will come in handy in case,

  • You are working on a load balancer migration project where your source is f5 or ACE or Netscalar and your target is NSX-ALB (formerly known as AVI Networks).
  • You have used the VMware provided migration-tool to convert your source LB config.
  • You have used cli-upload option or -o which is default to generate the output in a JSON formatted file instead of using auto-upload option which will push the converted config directly to the NSX-ALB Controller. For example on netscalar
1python3 netscalar_converter.py -f ./ns.conf --vs_filter test-vs --controller_version '21.1.4' --cloud_name Default-Cloud --vrf Test -o ./test
  • It might be that, you chose cli-upload option because you wanted to modify the converted config before pushing it to the NSX-ALB controller.
  • Now, after appropriate modification to the config file you need an option to upload this config to the NSX-ALB Controller which the current converter tool is not providing. Though there is an option in the current converter to patch the converted config with a YAML formatted file containing all the changes you would like to make in the converted AVI config file after conversion and then use auto-upload option in the same command to upload the patched config file to the controller.
1python3 netscalar_converter.py -f ./ns.conf --vs_filter test-vs --controller_version '21.1.4' --cloud_name Default-Cloud --vrf Test --patch test/patch.yaml -O auto-upload -c 2.2.2.2 -u username -p password -t tenant
  • You can use the above approach as well if you have prepared the patch.yaml file properly. But if you are manually changing the ns-Output.json which is the output file after conversion in step-3 above inside ./test directory, and after modification you are planning to push it to the controller, you can use this script for this purpose.

Usage

First of all, when you are trying to do this, you should already have avi.migrationtools or basically the entire alb-sdk repository cloned to your current system. If not, the process for doing this in a ubuntu machine is,

  • Intall python, pip and git in your system.
  • Using git clone the alb-sdk repository to your local system.
1git clone https://github.com/vmware/alb-sdk.git
  • Once you have a local copy of this repository, install the necessary modules to run the migration tools,
1cd alb-sdk
2./pip_create_install.sh

Going back to the original topic of config file upload, please download the avi_config_upload.py file from the link provided earlier. Run the script by providing the below options,

1python3 avi_config_upload.py --f <absolute-path-to-json-AVI-config-file> -u <username> -p <password> -t <tanent> -c <controller_ip> --controller_version <controller_version>

For example, in my case,

1python3 avi_config_upload.py --f ./test/ns-Output.json -u username -p password -t admin -c 2.2.2.2 --controller_version 21.1.4
2
3
4####Sending Config to AVI Controller####
5####Config Uploaded to Controller####

Now, you have your Json formatted config uploaded to the NSX-ALB Controller.

Last but not the least, the user which you will be using to send the config to the controller, should at least have the role Controller: Write Access under Administration along with other roles required to configure the NSX-ALB objects under sections Application, Profiles, Group and Script, Security etc. For example the user I used is having the the below roles as write-access.

And we are done!!