While trying to migrate a VM from a LUN to a VVOL I encountered an odd error, so I set up a number of test VMs to try the various programmatic ways to move the VM from the LUN to the VVOL but all were unsuccessful. To confirm I this was possible, I attempted a migration through the Web UI which was successful. Afterwards I used the successful VM to migrate to/from the LUN/VVOL without an issue.
This implies the Web UI is adjusting some configuration that I'm unable to identify/replicate.
Attempt 1 - Basic Move-VM
$cluster = Get-Cluster -Name "Test Cluster"
$vvol_datastore = Get-Datastore -Name "VVOL Datastore"
$lun_datastore = Get-Datastore -Name "LUN Datastore"
New-VM -Name "test1" -ResourcePool $cluster -Datastore $lun_datastore -NumCPU 1 -MemoryGB 1 -DiskGB 1
Move-VM -VM "test1" -Datastore $vvol_datastore
Move-VM : 5/25/2018 3:46:35 PM Move-VM The operation for the entity "test1" failed with the following message: "Error caused by file /vmfs/volumes/58af3eaf-dbba4e18-2e5e-10604b996f60/test1/test1.vmdk"
Attempt 2 - Use a RelocateSpec to set the profile during relocation
$cluster = Get-Cluster -Name "Test Cluster"
$vvol_datastore = Get-Datastore -Name "VVOL Datastore"
$lun_datastore = Get-Datastore -Name "LUN Datastore"
New-VM -Name "test2" -ResourcePool $cluster -Datastore $lun_datastore -NumCPU 1 -MemoryGB 1 -DiskGB 1
$vm = Get-VM -Name "test2"
$policy = Get-SpbmStoragePolicy -Name "VVOL Policy"
$profile_spec = New-Object VMware.Vim.VirtualMachineDefinedProfileSpec
$profile_spec.ProfileId = $policy.Id
$relocate_spec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$relocate_spec.Datastore = $vvol_datastore.ExtensionData.MoRef
$relocate_spec.Profile = $profile_spec
$relocate_spec.Disk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
$relocate_spec.Disk[0].DiskId = $vm.ExtensionData.LayoutEx.Disk.Key[0]
$relocate_spec.Disk[0].Datastore = $vvol_datastore.ExtensionData.MoRef
$relocate_spec.Disk[0].Profile = $profile_spec
$vm.ExtensionData.RelocateVM_Task($relocate_spec, "defaultPriority")
^ Fails with the same error as Move-VM
Worth noting:
- At any point, if I use the Web UI to migrate the VM to the VVOL, the above variations will work to move it to/from the LUN/VVOL
- If I create the VM directly on the VVOL, the above variations will work to move it to/from the LUN/VVOL
- There is a default storage policy set (same policy that I'm testing with), and the datastore is compatible with the test policy (Get-SpbmCompatibleStorage returns it)
- Using PowerCLI 10.1.0
Any ideas?