VMware Horizon Mirage is a layered image management solution that separates the PC into logical layers, which are owned and managed by either IT or the end user. Mirage enables enterprise IT administrators to centrally control the base and application layers guarantying a consistent view of the image across all endpoints. Through the Mirage Management Console, the administrator configures and manages clients, base images and app layers, performs operations such as updates and restores, and monitors the system operation through the dashboard and event logs.
In a SDDC environment automation is one the most critical pieces to ensure all parts work together. Despite Mirage provides all management capabilities via a full-featured dashboard, the lack of an supported API hinders the ability to promote datacenter automation.
So, I have 2 good news for Mirage administrators.
Good News N°1 – There is a web API in the Mirage Server. It’s hidden, clunky and undocumented – but it’s there.
Good News N°2 – I have created a VMware Mirage PowerShell Automation Module and I am sharing it with the broader community.
Important – the Mirage API approach is TOTALLY UNSUPPORTED BY VMWARE. I recommend testing in a development environment. If you decide to test or implement you are doing it on your own risk.
I am sharing this module with the borader community to enable administrators to create automation for Horizon Mirage taks via PowerShell. The cmdlets can be executed manually or be part of a larger PowerShell script, or even be triggered by automation and workflow tools like VCAC, vCenter Orchestrator or Puppet.
This version of automation module was created for and tested with Mirage V3.7_SP1 and no forward or backward compatibility is guaranteed. I know for fact that some of the cmdlets will not work with Mirage 4.0 and need to be updated given the Mirage API has changed since.
I am hoping that sharing this module with the community will enable administrators to understand how to implement it and build upon what I have created. If you update this module or add new functions and cmdlets I would appreciate you sharing back with the community.
The module contains the following functions:
The functions (cmdlets) are self-explanatory, but additional information about how to use it can be found in the module header. To load the module, open a PowerShell session and type “Import-Module -Name mirage_module.psm1”.
Download the module here.
Here are some examples of how to execute the cmdlets after the module has been loaded.
Connect-Mirage -mgmtHost "x.x.x.x" -username "administrator" -password "password" -DLLpath "C:\Program Files\VMware\Wanova\"
Get-MirageCollection -collection "collectioname"
Add-MirageCollection -collection "collectioname" -filter "mirage01"
Remove-MirageCollection -collection "collectioname"
Centralize-MirageEndpoint -Endpoint "endpointname" -BaseLayer "baseline"
DeCentralize-MirageEndpoint -Endpoint "endpointname"
Remove-MirageEndpoint -Endpoint "endpointname"
Get-MirageSnapshot -Endpoint "endpointname"
ConfirmRestore-MirageEndPoint -Endpoint "endpointname"
Suspend-MirageNetworkOperations -Endpoint "endpointname"
Resume-MirageNetworkOperations -Endpoint "endpointname"
Restart-MirageEndpoint -Endpoint "endpointname"
Assign-MirageBaseImage -Endpoint "endpointname" -BaseLayer "baseimagename" -MajorVersion 1 -MinorVersion 2
In order to support different version of VMware Horizon Mirage you will need to create a new DLL. To create a new DLL to make the module work with different versions of Mirage one should follow the following steps:
- Replace Management Server configuration (“baseAddresses”) – replace “localhost” in “ <http://localhost:8443/WanovaAd… with the actual machine address – required for the next step to work
- Create stub client code from WSDL: SvcUtil.exe
http://<Management address>:8443/WanovaAdmin?wsdl – creates LicensedAdminApi.cs
The resulting LicensedAdminApi.cs file will contain the service contract (the methods, resulting from the WSDL) and the data contracts (the data portion, coming from the XSD) for your service.
- Compile the client: csc.exe /t:library LicensedAdminApi.cs – creates LicensedAdminApi.dll
If you cannot find csc.exe in your environment please follow this instructions to detect what .NET Framework versions and service packs are installed. http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed
Please note that even with a new WSDL/DLL the PowerShell module would need to be fully tested for compatibility. The reason being is that the Mirage WEB API is constantly changing and is not supported for remote interaction.
This article was first published by Andre Leibovici (@andreleibovici) at myvirtualcloud.net.