For advanced manipulation of delta disks, you can use VirtualDeviceConfigSpec methods such as VirtualDeviceConfigSpec.create and VirtualDeviceConfigSpec.add.
Together add
and create
allow you to create a blank delta disk on top of an existing disk. For the VirtualDeviceConfigSpec you specify add to prepare the VM for a new delta disk, then create to initiate the file operation for the delta disk whose parent property is an existing disk. These methods create a new delta disk whose parent is the pre-existing disk.
One use case is adding a delta disk on top of an existing virtual disk in a virtual machine without creating a snapshot. Adding a Delta Disk Backing illustrates how to add the delta disk for the first virtual disk in the virtual machine.
Adding a Delta Disk Backing
disk = None for any of my VMs in dev if (VirtualDisk.isinstance == dev): disk = dev # Remove the disk removeDev = new VirtualDeviceConfigSpec() removeDev.operation = "remove" removeDev.device = disk # Create a new delta disk which has the # original disk as its parent disk addDev = new VirtualDeviceConfigSpec() addDev.operation = "add" addDev.fileOperation = "create" addDev.device = copy.copy(disk) addDev.device.backing = copy.copy(disk.backing) addDev.device.backing.fileName = "[" + disk.backing.datastore.name + "]" addDev.device.backing.parent = disk.backing spec = new VirtualMachineConfigSpec() spec.deviceChange = [removeDev, addDev]
For working code with a similar use case, see the JAXWS sample program VMDeltaDisk.java in the SDK under vsphere-ws/java.