Last active
November 15, 2018 18:44
-
-
Save ej-github/0f50dc0c3e6612060567c5881f85ba9c to your computer and use it in GitHub Desktop.
Inflate all Thin disks on vCenter VM to Thick Eager Zero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// | |
// Inflate all Thin provisioned disks on a vCenter VM to Thick Eager Zero | |
// | |
// For vRO 7.0+ | |
// | |
// Action Inputs: | |
// vmObject - VC:VirtualMachine - vCenter Virtual Machine | |
// | |
// Return type: void | |
var vmDatacenter = System.getModule("com.vmware.library.vc.basic").getDatacenterForVimObject(vmObject); | |
var virtualDisk = new VcVirtualDisk(); | |
var virtualDiskManager = vmObject.sdkConnection.virtualDiskManager; | |
System.log("Checking for thin disks to inflate..."); | |
for each (var device in vmObject.config.hardware.device) { | |
if (device instanceof VcVirtualDisk) { | |
virtualDisk = device; | |
//System.debug("device.unitNumber = "+device.unitNumber); | |
//System.debug("device.deviceInfo.label = "+device.deviceInfo.label); | |
//System.debug("virtualDisk.backing.fileName = "+virtualDisk.backing.fileName); | |
//System.debug("virtualDisk.backing.thinProvisioned = "+virtualDisk.backing.thinProvisioned); | |
//System.debug("virtualDisk.backing.eagerlyScrub = "+virtualDisk.backing.eagerlyScrub); | |
if (virtualDisk.backing.thinProvisioned) { | |
System.log("Inflating " + virtualDisk.backing.fileName); | |
var task = virtualDiskManager.inflateVirtualDisk_Task(virtualDisk.backing.fileName, vmDatacenter); | |
var taskResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,15) ; | |
} else { | |
System.log(virtualDisk.backing.fileName + " is not a thin provisioned VMDK. No action taken."); | |
} | |
} | |
} | |
// Uncomment to view disk info after inflate | |
/* | |
for each (var device in vmObject.config.hardware.device) { | |
if ((device instanceof VcVirtualDisk)) { | |
virtualDisk = device; | |
System.debug("device.unitNumber = "+device.unitNumber); | |
System.debug("device.deviceInfo.label = "+device.deviceInfo.label); | |
System.debug("virtualDisk.backing.fileName = "+virtualDisk.backing.fileName); | |
System.debug("virtualDisk.backing.thinProvisioned = "+virtualDisk.backing.thinProvisioned); | |
System.debug("virtualDisk.backing.eagerlyScrub = "+virtualDisk.backing.eagerlyScrub); | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment