vRealize Network Insight

Introducing the VMware vRealize Network Insight Python SDK

I’m very excited to introduce the VMware vRealize Network Insight Python SDK! Ever since the release of the public API for Network Insight almost 2 years ago, customers have taken advantage of the enormous breadth of data that is available and exposed by Network Insight.

Anything that you can find in the user interface is also available in the API and exportable. Here are a few example use cases that you could solve using the API.

  • Creating application constructs; tie in your automation system (like Cloud Automation Services) and have applications created in Network Insight when they are deployed
  • Export network flows to other systems (like a Security Information and Event Management system) to enrich their context
  • Retrieve IP bandwidth usage for billing (if you’re a service provider)

These are just a few examples of what’s possible. As all data inside Network Insight is available via the API, the possibilities are endless!

PowerShell Module

Before going into the Python SDK, I wanted to quickly mention the PowerShell module called PowervRNI. This module has been available for almost 2 years now and is being used by customers to solve automation use cases. More info on PowervRNI here. With the release of the Python SDK, we now both offer the options to automate using PowerShell and Python!

Python SDK

Working with this SDK is a breeze. It abstracts all the hard work and allows you to focus on only the task you actually want to accomplish; pulling data from Network Insight. The SDK itself is based on the OpenAPI specification and has all public API functions that are available. The good news is also that we’ve automated the generation of the SDK, so whenever Network Insight has new API functions; this SDK will support them soon thereafter.

The best part: this is an open source initiative and it’s hosted on GitHub! You can find it here: https://github.com/vmware/network-insight-sdk-python

Note: this also means that VMware does not officially support this project and the place to get help on it, is GitHub. Or you can reach out to me on twitter. 😉


I get my best inspiration from examples. That’s why we made sure that there are a bunch of examples in the repository, including the use cases from the top of this post. Not only that, there are examples to manage data sources, execute searches, manage settings and another extremely cool one: making a backup of your application constructs (and also restore them). More will be added with time. Feel free to contribute your own examples, as well!

Getting Started

First, download the SDK from GitHub and place it in a directory where you can work from. After downloading it, place the directory called swagger_client-py2.7.egg in your PYTHONPATH variable and you’ll be able to start building your scripts.

Network Insight Python SDK

There are a couple of files inside the examples directory that help get you started a little quicker. There is init_api_client.py which takes care of authentication against Network Insight and make it easy to get connection details by using parameters and sdk_utilities.py and utilities.py which take care of things like logging. All examples currently use these files to offload some of the tedious work. When you’re creating your own script, take advantage of these utility functions.

Each of the API sections (Authentication, Entities, Applications, etc.) has its own objects with all available API endpoints as functions. This means that it’s pretty easy to get things done, for example, the authentication against Network Insight takes just a few lines:


Running this snippet will result in an authentication token which can be used for subsequent calls:

Network Insight Python SDK Sample output

Using the Utilities

Now for something with a little more meat to it; let’s do a search for all virtual machines that are attached to a specific vCenter. I’ll also use the utilities that are located in the examples directory, to abstract away things like having to bother with the authentication token.


Let’s go through this snippet line by line:

  • 1-3: Import the SDK and utilities.
  • 6-7: Get connection details using the utilities and instantiate a connection.
  • 10: Create a search object, which houses all available API calls for search.
  • 13-14: Generate the search request based on Virtual Machine objects, use the filter and give a page size of 100 results per page.
  • 17-18: Execute the API request and return the results!

Easy, right? Here’s how you would use this script:

Network Insight Python SDK Search VM Output

I’ve truncated the output, but you can see the results value is a list of all virtual machines. You can then take the entity_id value and request the details of that specific virtual machine.

Go for it!

There is a lot more in the examples of this Python SDK. Building new scripts with the SDK is easy though, we’ve tried to make it as easy as possible.

Please let us know if you find a use case that we have not covered yet. We’re looking forward to growing the examples over time!



Leave a Reply

Your email address will not be published. Required fields are marked *