Aug 10 2014

Using Nutanix Java SDK for Automation – Sample Code and Repo

DevOps is a response to the growing awareness that there is a disconnect between what is traditionally considered development activity and what is traditionally considered operations activity. For the business, DevOps contributes directly to enabling business agility and IT alignment.

Software vendors working with Nutanix to integrate their software stack into the Nutanix PRISM APIs allowing applications to drive infrastructure requirements such as security, availability, reliability and performance. These requirements go well beyond software defined storage configurations, but I leave this subject for another day.

That said, there is an increasing need for enterprise automation and it is Nutanix job to provide the means to make it happen. You should expect Nutanix to provide modules and integrate directly with configuration management, provisioning and orchestration tools such as Puppet, BMC, Chef, vCenter Orchestrator, SCOM, vCOPS and others; but you will also see Nutanix PRISM development kits for Java, Python, PowerShell and others languages be made available soon. As matter of fact Java and PowerShell are already available.

 

The Java SDK

As announced in one of my previous posts NOS 4.0 now ships with a Java SDK inside the nCLI package. In the PRISM UI there is a download nCLI option that will download a zip file containing the ncli.cmd and extra .jar files under the lib folder. There you will find the prism_sdk_rest.jar, the Nutanix Java SDK that uses PRISM REST APIs.

 

The first release of the Java SDK does not include binary dependencies, so you would need to map dependencies one-by-one and download them from multiple sources. Fortunately, we have done the work for you and you won’t have to track dependencies. The sample Java code that I have uploaded to the Nutanix Repository contains all the required binaries, exemplifies how to connect to PRISM API and execute few queries.

Click here to go to repository.

 

In the Java code being provided you will find all the required binaries and couple initial sample functions, including: getVMsgetDisksgetHostsgetContainersgetManagementServers and getProtectionDomains. For my next article I will include functions to change virtual machine availability, create new containers or protection domains etc.

In the  code the ServerConnectionManager class is responsible for API connectivity and should be first instantiated ‘connMgr‘. Once the connection to PRISM is successful other objects may be instantiated.

		// Stablish connection with PRISM API
		final ServerConnectionsManager connMgr = ServerConnectionsManager
				.getInstance();
		connMgr.setUSERNAME("admin");
		connMgr.setPASSWORD("admin");
		connMgr.setSERVER("10.20.18.10");

		// Retrieve list of virtual machines and properties
		System.out.println();
		System.out.println("Virtual Machines");
		final VMAdministration ref4 = connMgr.getVMAdministration();
		final List vms = ref4.getVMs(null, null, null).getEntities();
		final Iterator iteratorVms = vms.iterator();
		while (iteratorVms.hasNext()) {
			System.out.println(iteratorVms.next());
		}

 

Classes

Nutanix does not have yet documentation for the Java SDK, but it is safe to say that the entire PRISM API feature-set has been made available via the SDK. The classes I find myself using the most are related to hosts, VMs, health check and protection domains, but there are also classes specific to hypervisor configuration, multi clusters, virtual disk administration, licensing and others. If you want to see the entire list of classes, click here.

 

Self-Signed Certificate

One of the challenges I faced in my Nutanix lab environment was a self-signed certificate, so I implemented a class that ignores the original self-signed certificate – NullTrustManager.java. While this is bad 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.

 

Sample Code Results

The sample code will list VMs, Containers, Hosts, Disks, Protection Domains and Management Servers. The results are iterated thought and printed to the console. Here is the results after running the code.

(Click to Enlarge)

Screen Shot 2014-08-10 at 4.44.35 PM

 

REST API Explorer

Some of the Java objects in the SDK will require knowledge about their entities and fields. Since there is no documentation at this point you can simply go to the REST API Explorer and PRISM and identify what should be provided in each of the fields or objects.

(Click to Enlarge)

Screen Shot 2014-08-10 at 5.31.50 PM

 

If you happen to build any interesting function please share it with me and I will add to the Sample Code in GitHub.

I would like to thank Nutanix engineer Vamsi Krishna for compiling the first version of the sample code.

 

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

Permanent link to this article: http://myvirtualcloud.net/?p=6523

Aug 03 2014

The new Nutanix Script Repository

The new Nutanix Script Repository is dedicated to the system administrator scripters of the world whom use automation to reduce time spent performing mundane tasks. Overtime you will find resources written in PowerShell, Java, Python and other script languages.

You can simply download the scripts or interact with them using Git. Git is an open-source version-control system designed to handle projects that are distributed over multiple repositories and developers. We use Git for local operations such as local branching, commits, diffs, and edits.

Each script repository provides information like an associated blog post, information related to changes to the script overtime, or other useful information.

 

 

Here are some of the scripts currently in the repository.

  • Change Nutanix CVM RAM
  • PowerShell Connection to Nutanix using Invoke-RestMethod
  • Manually Fingerprint vDisks
  • Mass Clone and Power VMs via vCenter using VAAI
  • Produce Nutanix Protection Domain Report
  • Produce Nutanix vDisk Report
  • Configure basic Nutanix cluster

 

Each contribution is licensed to you under a License Agreement by its owner, not Nutanix. Nutanix does not guarantee the contribution or purport to grant rights to it. Some scripts are licenses under the MIT License (MIT).

 

To access the Nutanix Script Repository click here.

 

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

Permanent link to this article: http://myvirtualcloud.net/?p=6517

Jul 31 2014

Nutanix One-Click Upgrade now takes care of Firmware and Hypervisor too!

As the name says, it’s a One-Click upgrade for the entire Nutanix cluster. Nutanix One-Click upgrade automatically indicates when a new NOS version is available and it will auto-download the binaries if the auto-download option is enabled. With a single-click to upgrade all nodes in a cluster, Nutanix uses a highly parallel process and reboot one CVM at a time using a rolling upgrade mechanism. The entire cluster upgrade can be fully monitored by the administrator.

During the upgrade process a feature called Autopathing kicks-in redirecting VM I/Os on the Hypervisor host to another CVM (Nutanix Controller) on a different hypervisor host. This has several benefits including allowing you to upgrade a CVM without disruption. The CVM AutoPathing prevents performance loss during rolling upgrades minimizing I/O timeout by pre-emptively redirecting storage traffic to other CVMs. Failover traffic is also automatically load-balanced with the rest of the cluster based on node load.

 

What’s New?

For most of you already running Nutanix 4.0.1 this is not new. However, this time around I am writing about the new One-Click upgrade feature being released with the next NOS release. In addition to the already non-disruptive NOS upgrade, the One-Click upgrade feature now ensures that the hypervisor (vSphere, HyperV and KVM) is also automatically upgraded in a distributed and rolling fashion. Nutanix is solving a huge problem, where either manual intervention or external automation tools are required.

In addition to the new hypervisor upgrade feature Nutanix is now enabling NCC (Nutanix Cluster Health) upgrade and hardware firmware upgrade. Let’s talks about firmware upgrade.

Upgrading firmware on servers, controllers, disks and other interfaces is probably one of the major pain points for datacenter administrators. The workflow normally goes as follows: schedule maintenance outage, go to the manufacturer website, download correct firmware, flash firmware via web interface or with a Linux cli tool, reboot server, and then repeat this task for every server in the datacenter that require firmware upgrade. It’s complex and lengthy.

Because NOS runs in hypervisor user space Nutanix is able to execute complex firmware and hardware upgrade processes across multiple server components without requiring reboots. Using Nutanix a highly distributed parallel processing the One-Click upgrade takes care of firmware upgrade for all disk devices in the cluster with zero impact to virtual machines and workloads. No reboots required, true AlwaysOn! It isn’t hard hard to see or predict Nutanix taking care of all other components in the cluster in a foreseeable future.

As a bonus the framework that is serving as the engine for the Nutanix Cluster Health, also knows as NCC, is also part of the One-Click upgrade process. Read more about NCC here.

Below you will find a screenshot of a Beta NOS release that supports upgrades for NOS, Hypervisor, Disk Firmware and NCC. As I have more non-NDA content about the new One-Click upgrade I will share it here. This is true Nutanix innovation and something that only software defined solutions can achieve via heavy use of automation and workflows.

 

 

Note: The hypervisor upgrade process requires server reboot.

 

If you have not yet seen the current release of Nutanix One-Click upgrade click Nutanix One-Click Upgrade Demo Video (Simple & Easy).

 

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

Permanent link to this article: http://myvirtualcloud.net/?p=6503

Older posts «

» Newer posts