Today I had an experience that was not very different than some of the ‘I was today years old’ memes which are floating on the web. I was working on a script to detach a LUN on all hosts within a cluster when I stumbled on a contribution from LucD in the VMware Technology Network.
Now I already knew the vSphere Web Services API had a method to detach a LUN (DetachScsiLun), but was unaware of a variant that will run asynchronously (DetachScsiLunEx_Task). The latter being of course much faster. This led me to browse the API reference documentation and found that there are actually more methods with the Ex_Task suffix.
Method | Managed Object | Since |
AttachScsiLunEx_Task | HostStorageSystem | 6.0 |
ConfigureVFlashResourceEx_Task | HostVFlashManager | 5.5 |
CreateSecondaryVMEx_Task | VirtualMachine | 6.0 |
CreateSnapshotEx_Task | VirtualMachine | 6.5 |
DeleteVStorageObjectEx_Task | VcenterVStorageObjectManager | 7.0.2.0 |
DetachScsiLunEx_Task | HostStorageSystem | 6.0 |
HostDeleteVStorageObjectEx_Task | VcenterVStorageObjectManager | 7.0.2.0 |
HostUpdateVStorageObjectMetadataEx_Task | VcenterVStorageObjectManager | 7.0.2.0 |
MarkPerenniallyReservedEx_Task | HostStorageSystem | 6.7.2 |
MountVmfsVolumeEx_Task | HostStorageSystem | 6.0 |
QueryVMotionCompatibilityEx_Task | VirtualMachineProvisioningChecker | 4.0 |
RemoveDatastoreEx_Task | HostStorageSystem | 6.0 |
ResolveMultipleUnresolvedVmfsVolumesEx_Task | HostStorageSystem | 5.5 |
UnmapVmfsVolumeEx_Task | HostStorageSystem | 6.0 |
UnmountVmfsVolumeEx_Task | HostStorageSystem | 6.0 |
VCenterUpdateVStorageObjectMetadataEx_Task | VcenterVStorageObjectManager | 7.0.2.0 |
As you can see from the table above some of these methods have been around for quite a while. And the list has grown over time.
For my purposes the DetachScsiLunEx_Task and UnmountVmfsVolumeEx_Task are the most useful. But there are of course more use cases, like this post from vcloudvision co-author Bryan which used esxcli but could just as easily used the MarkPerenniallyReservedEx_Task method.
One thing to note is that when using running tasks asynchronously you need to approach error handling differently. But if you monitor the progress in vCenter like I do for most batch operations you’ll be fine.
For more information on the above mentioned methods, head on over to the API reference for the vSphere Web Services API on developer.vmware.com.
I hope that this finding is of use to you too. Happy multitasking!
0 Comments