Creating a VM incl a vGPU profile on AHV with Powershell

Powershell

Hello old friend, here we are again. It’s been a while but I’m (hopefully) getting back on track with this blog. I’ve been dabbling around with this idea for a while and it got fastracked after I got a request from someone in the Nutanix Services Organisation on how they could add a vGPU profile to the ‘Create a VM on AHV’ with Powershell.

From that older blog, the following interfaces are available:

  • REST API
  • HTML5 GUI
  • CLI – ACLI & NCLI
  • Scripting interfaces (PowerShell)

The following definitions are from the Nutanix Bible as Steve Poitras already explained this:

REST API
The REST API exposes every capability and data point of the Prism UI and allows for orchestration or automation tools to easily drive Nutanix action.  This enables tools like Saltstack, Puppet, vRealize Operations, System Center Orchestrator, Ansible, etc. to easily create custom workflows for Nutanix. Also, this means that any third-party developer could create their own custom UI and pull in Nutanix data via REST.
HTML5 GUI (Prism UI)
The HTML5 UI is a key part to Prism to provide a simple, easy to use management interface.  However, another core ability are the APIs which are available for automation.  All functionality exposed through the Prism UI is also exposed through a full set of REST APIs to allow for the ability to programmatically interface with the Nutanix platform.  This allow customers and partners to enable automation, 3rd-party tools, or even create their own UI.
CLI – ACLI & NCLI
The Acropolis CLI (ACLI) is the CLI for managing the Acropolis portion of the Nutanix product.  These capabilities were enabled in releases after 4.1.2. The Nutanix CLI is the CLI for managing the Nutanix product and is more heterogeneous across hypervisors.
PowerShell
Windows PowerShell is a powerful shell (hence the name ;P) and scripting language built on the .NET framework.  It is a very simple to use language and is built to be intuitive and interactive.

As a reminder, when creating a VM via ACLI all you’d need is a few lines to create a VM, assign a nic to the VM on a specific network and do the same with a disk (create/assign). Now adding a GPU is another oneliner:

Now, to do this with powershell it proved to be a little bit more challenging than I expected it to be as our native cmdlets didn’t seem to have a good way of doing this so I had to revert to good old REST APIs and Powershell so with some help from Michell and Dave here’s what I came up with:

The result of running this script

Hopefully this helped you guys as I’m off to my next challenge (Thanks Dave) to write this into a C# application.

The following two tabs change content below.

Kees Baggerman

Kees Baggerman is a Staff Solutions Architect for End User Computing at Nutanix. Kees has driven numerous Microsoft and Citrix, and RES infrastructures functional/technical designs, migrations, implementations engagements over the years.

2 comments

  1. […] Creating a VM including a vGPU profile on AHV with Powershell […]

  2. […] writing the script to create VM on AHV with a vGPU profile I was wondering what else I could do with the code I had written. When I was looking at some of my […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.