Automation

 View Only
  • 1.  Cloning VMs with thin disks to NFS datastore

    Posted Aug 19, 2020 04:31 PM

    I've adapted code from here to add to my Simple VMware GUI script for backing up VMs. It works fine for VMFS to VMFS but if the destination datastore is NFS I get "The virtual disk is either corrupted or not a supported format" when I call CloneVM_Task for the VM which I'm guessing is because the source VM is using thin disks which are a feature of VMFS so can't be on NFS.

    The original script set the "transform" property of the VirtualMachineRelocateSpec object but after RTFM ​it says that this is deprecated and ignored and that I should be using diskBackingInfo instead but I can't find any examples close enough to what I'm trying to do to plagiarise (with credit given, as ever!) and can't make sense of the documentation so has anyone attempted similar please, e.g. cloning VMs with thin disks to NFS or at least made them non-thin? I was hoping to be able to do it all in the spec passed to CloneVM_Task rather than having to explicitly copy the disks from the source which I've got code for but was hoping to avoid.

    Thanks in advance.

    Guy

    @guyrleech



  • 2.  RE: Cloning VMs with thin disks to NFS datastore

    Posted Aug 19, 2020 05:29 PM

    I'm not really sure what is causing that issue.

    When I clone a VM with a Thin VMDK to an NFS-backed datastore, the cloned VMDK on the target dastore is automatically converted to Thick Eager-Zeroed.

    $vmName = 'TestVM'

    $dsName = 'NFSDS'


    $sViewDS = @{

        ViewType = 'Datastore'

        Property = 'Name'

        Filter = @{Name=$dsName}

    }

    $ds = Get-View @sViewDS


    $sViewVM = @{

        ViewType = 'VirtualMachine'

        Filter = @{Name=$vmName}

    }

    $vm = Get-View @sViewVM

    $spec = New-Object VMware.Vim.VirtualMachineCloneSpec

    $spec.Location = New-Object VMware.Vim.VirtualMachineRelocateSpec

    $spec.Location.Datastore = $ds.MoRef


    $vm.CloneVM($vm.Parent,"$($vmName)_Clone",$spec)

    Did you check the vpxd log for info on the error?

    Perhaps switch the logging temporarily to 'verbose' on the VCSA.