An issue arose however with the release of the vSphere Web Client, since Project Onyx did not support that method of intercepting calls. When VMware started moving new functionality only into the Web Client, that meant you could not use Project Onyx to figure out the code for those new features.
Enter a new VMware Fling – Onyx for the vSphere Web Client!
Some smart guys have now brought this same functionality to the vSphere Web Client. Let’s take a look at an example of how it works.
First of all follow the instructions on the Fling site to get it installed. Currently it supports vCenter 6.0. Note the warning about only using this Fling in your test environment (that’s where you write and test all of your code anyway right? 😉 )
WARNING: This fling replaces core Web Client files and may cause issues with stability and
patching of future versions of the web client, please only continue with this installation if you are
using a test or dev environment.
Once installed and the vSphere Web Client service has restarted, you will see a new menu item for Onyx.
You can either Start and Stop recording from this area or very handily they have added the same buttons in the top right hand corner so that you can Start and Stop recording from anywhere in the Web Client.
So start the recording and navigate to the thing that you want to do. For this example we’ll turn on HA for a cluster.
Once complete, stop the recording.
Now head back to the Onyx section of the Web Client and observe the code required to make that change.
$spec = New-Object VMware.Vim.ClusterConfigSpecEx $spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo $spec.dasConfig.vmComponentProtecting = 'disabled' $spec.dasConfig.enabled = $true $spec.dasConfig.admissionControlEnabled = $true $spec.dasConfig.vmMonitoring = 'vmMonitoringDisabled' $spec.dasConfig.hostMonitoring = 'enabled' $spec.dasConfig.HBDatastoreCandidatePolicy = 'allFeasibleDsWithUserPreference' $spec.dasConfig.admissionControlPolicy = New-Object VMware.Vim.ClusterFailoverLevelAdmissionControlPolicy $spec.dasConfig.admissionControlPolicy.failoverLevel = 1 $spec.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings = New-Object VMware.Vim.ClusterVmComponentProtectionSettings $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmReactionOnAPDCleared = 'none' $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings.enableAPDTimeoutForHosts = $true $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmStorageProtectionForAPD = 'disabled' $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmTerminateDelayForAPDSec = 180 $spec.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmStorageProtectionForPDL = 'disabled' $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.failureInterval = 30 $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailures = 3 $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow = 3600 $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.minUpTime = 120 $spec.dasConfig.defaultVmSettings.restartPriority = 'medium' $spec.dasConfig.defaultVmSettings.isolationResponse = 'none' $spec.dasConfig.option = New-Object VMware.Vim.OptionValue (0) $spec.dasConfig.heartbeatDatastore = New-Object VMware.Vim.ManagedObjectReference (0) $spec.dasConfig.hBDatastoreCandidatePolicy = 'allFeasibleDsWithUserPreference' $modify = $true $_this = Get-View -Id 'ClusterComputeResource-domain-c22' $_this.ReconfigureComputeResource_Task($spec, $modify)
This is super cool. I really like the way it’s been implemented and looking forward to further development of this Fling 🙂