Nutanix Java SDK for Open-Source Community

I am always tinkering with new projects to keep me busy and more recently I started working on an integration between my VDI Calculator and Nutanix PRISM API. The whole idea is to be able to collect information from Nutanix and pre-fill the calculator with important data to forecast growth and run a capacity management analytics for large VDI environment. This is still in the works, but for that end I created a small amount of code to allow my application to interact with the Nutanix PRISM API using Java.

[UPDATE] It turns out I was wrong. Nutanix already has a Java SDK!

Nutanix offers today a fully featured REST API and Powershell SDK. I quickly realized that having this code in a consumable manner would allow DevOps engineers to create their own Java automation and integrations with the Nutanix platform.

I externalized the code and created the underpinnings for a Java SDK. This is an initial and very simple release and I will contribute more overtime. The code is governed by GNU General Public License and is intended to guarantee your freedom to share and change the software.

You are free to contribute and upstream code improvements and additions. I am also thinking about extending this SDK to allow tight integration with other systems, like vSphere, SCVMM, Puppet, Backup tools, run-book automation tools etc…

The SDK uses Apache Commons HttpClient project to interact with Nutanix PRISM REST API  and Google’s json-simple Toolkit to encode or decode JSON text.

Nutanix-Prism-Java-SDK is hosted in GitHub (here)

If you want to use the SDK in your Java project just download and add Nutanix_Prism_Java_SDK_v1_0.jar into your Java application building path and instantiate objects. I have implemented Connection, Hosts, Vm and VirtualDisks classes, but I have only included few methods in each class, mostly ‘Get’.


[css lang=”plain” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ padlinenumbers=”false” gutter=”true” smarttabs=”true” toolbar=”true” language=”true”]

final com.nutanix.prism.Connection prismConnect = new Connection();
final com.nutanix.prism.Hosts prismHost = new com.nutanix.prism.Hosts();
final com.nutanix.prism.Vm prismVm = new com.nutanix.prism.Vm();
final com.nutanix.prism.VirtualDisks prismVirtualDisk = new com.nutanix.prism.VirtualDisks();
prismConnect.connect("IP_Address", "admin:admin");


One of the challenges I faced in my Nutanix lab environment was a self-signed certificate, so I implemented a function that ignores the original self-signed certificate. While this is a very bad coding and security practice I am not planning to implement a valid certificate in my lab environment. I suggest that you implement a valid signed certificate from a trusted root CA authority in your production Nutanix environment. For a next code update I will make sure it’s possible to specify if the connection should be trusted or not.


[css lang=”plain” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ padlinenumbers=”false” gutter=”true” smarttabs=”true” toolbar=”true” language=”true”]

* Ignore SelfSigned Certificate
* @return SSLConnectionSocketFactory */
protected static final SSLConnectionSocketFactory verifyHostname() {

final SSLContextBuilder builder = new SSLContextBuilder();
SSLConnectionSocketFactory sslsf = null;

try {
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
} catch (final NoSuchAlgorithmException e) {
return null;
} catch (final KeyStoreException e) {
return null;

try {
sslsf = new SSLConnectionSocketFactory(,
} catch (final KeyManagementException e) {
return null;
} catch (final NoSuchAlgorithmException e) {
return null;

return sslsf;


This article was first published by Andre Leibovici (@andreleibovici) at

Leave a Reply