One of the things that I am most excited about from an Automation standpoint with the vSAN 6.6 release is that customers using PowerCLI will now have complete access to the vSAN Management API which we had initially introduced back in vSphere 6.0 Update 2. In PowerCLI 6.5R1, customers only had access to high level vSAN cmdlets which did a pretty good job covering the broad set of vSAN functionality. However, it did not expose the complete vSAN Management API and this has been something many customers have been asking about.
With the new PowerCLI 6.5.1 release, a new Get-VsanView cmdlet is now available that will exposes the complete vSAN Management API using PowerCLI. Since the vSAN Management API has been around since vSphere 6.0 Update 2, you will also be able to use this new cmdlet against a vSAN 6.2, vSAN 6.5 and vSAN 6.6 environment! You simply just need to update your PowerCLI installation which you should always do to get the latest fixes and enhancements.
When you connect to either a vCenter Server and/or ESXi host, you will be able to view all available vSAN Managed Objects for the system by simply running the cmdlet without any arguments as shown in the screenshot below.
If you wish to access a specific vSAN Managed Object type, then you will need to pass in the vSAN MoRef ID from the given list. Here is an example of accessing the "VsanVcClusterHealthSystem-vsan-cluster-health-system" which will give us access to the VsanVcClusterHealthSystem.
Get-VsanView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system"
Once we have access to the specific vSAN Managed Object, then you can access it like you normally would by piping that into Get-Member (gm) to see what operations are available which you should refer to the vSAN Management API for more details.
Lets go through a complete example demonstrating how to access one of the vSAN Management APIs, specifically with retrieving the version of vSAN both from a vCenter Server and ESXi standpoint. The following PowerCLI function (can also be downloaded here) will connect to the vSAN Health System and use the VsanVcClusterQueryVerifyHealthSystemVersions() method and passing in a vSAN Cluster to retrieve the version information.
Function Get-VSANVersion { param( [Parameter(Mandatory=$true)][String]$Cluster ) $vchs = Get-VsanView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system" $cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef $results = $vchs.VsanVcClusterQueryVerifyHealthSystemVersions($cluster_view) Write-Host "`nVC Version:"$results.VcVersion $results.HostResults | Select Hostname, Version }
To use this function, simply connect to your vCenter Server and pass in the name of a vSAN Cluster as shown below:
Get-VSANVersion -Cluster VSAN-Cluster
From the output, we can see the version of vSAN at the vCenter Server level as well as for the individual ESXi host which can be handy if you want to check the current running version before performing an upgrade. Hopefully this provided you with a nice overview of the new Get-VSANView cmdlet and how to access the vSAN Management API. I think this is going to open the door for all sorts of cool vSAN Automation use cases with PowerCLI, look forward to seeing what the community comes up with!
Additional vSAN Mgmt API/PowerCLI Sample:
Lastly, I thought it might be useful to provide a nice table summarizing the vSAN Managed Objects that are available when connecting to either a vCenter Server and/or ESXi host which could also be used as quick reference. Another handy resource is the vSAN Management 6.6 API Quick Reference that I have created which will provide you a nice overview of the entire vSAN Management API as well as links to the API reference on how to use the APIs. Definitely worth bookmarking for those looking to do some vSAN Automation using the new PowerCLI Get-VsanView!
vCenter Server
vSAN Managed Object | vSAN MoRef ID |
---|---|
VsanCapabilitySystem | VsanCapabilitySystem-vsan-vc-capability-system |
VsanVcClusterConfigSystem | VsanVcClusterConfigSystem-vsan-cluster-config-system |
VsanVcStretchedClusterSystem | VimClusterVsanVcStretchedClusterSystem-vsan-stretched-cluster-system |
VsanVcDiskManagementSystem | VimClusterVsanVcDiskManagementSystem-vsan-disk-management-system |
VsanVcClusterHealthSystem | VsanVcClusterHealthSystem-vsan-cluster-health-system |
VsanUpgradeSystemEx | VsanUpgradeSystemEx-vsan-upgrade-systemex |
VsanSpaceReportSystem | VsanSpaceReportSystem-vsan-cluster-space-report-system |
VsanIscsiTargetSystem | VsanIscsiTargetSystem-vsan-cluster-iscsi-target-system |
VsanVdsSystem | VsanVdsSystem-vsan-vds-system |
VsanPhoneHomeSystem | VsanPhoneHomeSystem-vsan-phonehome-system |
VsanMassCollector | VsanMassCollector-vsan-mass-collector |
VsanPerformanceManager | VsanPerformanceManager-vsan-performance-manager |
VsanObjectSystem | VsanObjectSystem-vsan-object-system |
VsanVcsaDeployerSystem | VsanVcsaDeployerSystem-vsan-vcsa-deployer-system |
VsanUpdateManager | VsanUpdateManager-vsan-update-manager |
ESXi
vSAN Managed Object | vSAN MoRef ID |
---|---|
HostVsanHealthSystem | HostVsanHealthSystem-ha-vsan-health-system |
VsanPerformanceManager | VsanPerformanceManager-vsan-performance-manager |
VsanObjectSystem | VsanObjectSystem-vsan-object-system |
VsanVcsaDeployerSystem | VsanVcsaDeployerSystem-vsan-vcsa-deployer-system |
VsanUpdateManager | VsanUpdateManager-vsan-update-manager |
Roman Gelman says
Hi William,
Great article.
The community comes up with VSAN PowerCLI module
https://github.com/rgel/PowerCLi