AHV, API, English

VM self service from within the VM

Matthijs asked me if I could create a script which would allow the user to self initiate a report from within a virtual machine. Since Nutanix is API first this shouldn’t be too much of an issue. A little bit of PowerShell magic should do the trick. Whilst creating this I got a little bit carried away. As a result I transformed the request into a tool to have VM self service from within the VM itself. API based Powershell in-guest tools. Compiled as a single executable for 1-click Experience. Please note, this is not official Nutanix software, use at your own risk.

GitHub Project

The GitHub project may be found at https://github.com/MMouse-23/GuestVMTools. The version described in this blog is 1.0.0.0.

Requirements

  • Windows Machine with PowerShell 5.
  • Prism Central Credentials, Local or Directory Based, no SSH access required.
  • Prism Central role based access control rights to execute requested actions.
  • AOS 5.16 or above for Secure Boot.
  • Prism Central / AOS on 5.9 or above for API V3.
  • A mouse, physical tool being used to control a graphical user interface through the use of a graphic pointer on the screen. Readily available through web shops.

Installation Instructions

  1. Download the project from GitHub
    • Click
    • Choose “Download ZIP
    • Store the .zip file in a temporary place
  2. Open the .zip file
    • Browse to the folder Compiled
    • Copy the file GuestVMTools.exe to a location of your liking
  3. Add to the Windows menu
    • Right click the GuestVMTools.exe and create a shortcut
    • Browse to :
      “%homedrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\”
      • Tip: Windows key plus R will open a run command window where you can parse this path and it will open the exact location.
    • Create a folder with a name of your choosing
    • Go back to the location where you created the shortcut and move the shortcut into the start menu folder you just created
  4. You can now start the GuestVMTools from the Windows start menu

Powershell based installation

  1. Download the project from GitHub
    • Click
    • Choose “Download ZIP
    • Store the .zip file in a temporary place
  2. Extract the .zip file
    • Right click the GuestVMTools-master.zip
    • Choose “Extract All…” from the drop down menu
    • Follow the instructions in the wizard to store the repository

Usage Instructions

There are 2 methods to run the GuestVMTools as described below.

Executeable 

Launch the GuestVMTools shortcut from the Windows start menu and follow the instructions on screen.

Powershell

Run GuestVMTools.ps1 from the location you stored it. Please make sure the pwd (active local path) is changed to the repo (location where the script is stored) before you launch. Extracting the full GitHub repository as included in the .zip file is a pre-requisite. These steps are outlined in the section named powershell based installation.

Capabilties

  • Report 
    Reports the VM Details, on which host its running and host performance.
  • Add-Ram 
    Adds memory to the VM, regardless of power state.
  • Add-Disk 
    Adds a disk to the local or targeted VM.
  • Extend-Disk 
    Extends a disk to the local or targeted VM.
  • Enable-SecureBoot 
    Remote targets only, poweroff required.
  • Snapshot-Create 
    Creates a snapshot of the local or targeted VM
  • Set-VM-Description 
    Sets the VM description of the local or targeted VM
  • Mount-ISO 
    Mounts an ISO from the Prism Element image store on which the VM is hosted.
  • Mount-NGT 
    Mounts Nutanix Guest Tooling (NGT) to the local or targeted VM

Report

This function connects to the Prism Element host to which this virtual machine belongs. It then reports information like the virtual machine configuration. As well as information about the Nutanix environment it runs in, such as the type of physical hardware and uptime of the virtual machine.

GuestVMTools report function in action.
Report function

Generation of the report finishes with a prompt to save the results CSV format. The screenshot below shows you how such a report looks like in Microsoft Excel.

Screenshot of the CSV report in Excel.
CSV Output in Microsoft Excel

Add-Ram

As the title suggest the Add-Ram function adds memory to the running or targeted VM. Confirms the change by prompting the new value, if this value is the same your Nutanix cluster cannot assign more. Does not support downsizing memory assigned.

GuestVMTools add RAM function in action.
Add memory to the VM as self service through Add-Ram function

Add-Disk

Addition only, Add-Disk adds a disk to the running or targeted VM. Prompts for a target container to store the disk. Confirms the change by checking the Prism task result. Currently only supports the addition of SCSI Disks.

GuestVMTools animated gif of Add Disk functionality.
Add-Disk function in action

Extend-Disk

Extend-Disk prompts the user for the disks mounted to the target VM. Currently SCSI Disks are the only supported disks. Prompts the user for the desired new disk size. Confirms the change by checking the prism task result.

GuestVMTools animated gif of Extend Disk functionality.
Extends existing disk through Extend-Disk function

Enable-SecureBoot

Since AOS 5.16 Secureboot is supported, however CLI or API only, there is no UI button yet. Enable-SecureBoot is here to help you out. Note that this is a disruptive action. This tool allows to enable secureboot on any VM, poweroff, etc. Prior to execution all pre-requisites which are required for secure boot are checked. Prompts the user several times depending on power state and drives present. IDE disks cannot be handled, IDE CDrom drives (multiple) are replaced on user approval. Confirms the task by retrieving the secureboot value. Works only on targeted VMs. As it requires a running environment to send the controls from.

GuestVMTools animated gif of enabling secure boot functionality.
Enable-SecureBoot sequence in action

Snapshot-Create

With Snapshot-Create this the user is enabled to initiate a Prism Element based snapshot. Prompts the user for the snapshot name followed by the creation of the snapshot.

GuestVMTools animated gif of self initiated VM snapshot from within the VM.
User initiated snapshot from within the VM with Snapshot-Create function

Set-VM-Description

Changes the description of the Virtual Machine as it is displayed within Prism. Set-VM-Description prompts the user for the description.

GuestVMTools animated gif of change VM description in Prism functionality.
Have the user set their own description of the VM with Set-VM-Description

Mount ISO

No not Mount Isa, Mount an ISO image. Prompts the user for ISOs present on the local Prism Element of the VM. Checks if there is an empty cdrom drive. Prompts the user to confirm auto eject if no drive is empty. Mounts the image as a clone from the image service to the cdrom drive. Confirms the task by following the Prism progress monitor.

GuestVMTools animated gif showing the mount ISO functionality
Mount an ISO from the repository

Mount NGT

Checks if there is an empty cdrom drive. Prompts the user to confirm auto eject if no drive is empty. Mounts the Nutanix Guest Tooling to the free cdrom drive, with validation if this succeeded.

Nutanix Guest Tooling enables advanced multi-cloud migration, Microsoft Volume Snapshot Service better known as VSS and self service restore capabilities. These functionalities differ from those offered here and do require network access rules to be set. This is not to be confused with Vmware tools, as these are entirely optional. The functionality offered through the tool here makes it easier to install the Nutanix Guest Tools, if such is desired.

GuestVMTools animated gif showing the mount Nutanix Guest Tools (NGT) functionality.
Mount Nutanix Guest Tools (NGT)

Summary

I hope you and your power users will find this VM self service from within the VM useful. Please feel free to contribute to the project on GitHub. Thank you for reading and please provide me with any feedback you have!

Leave a Reply

We'r using cookies to see how many people read our blogs

We're interested in how many people view our blogs, please accept the cookies if you're okay with that.