Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 201333

Which Folder for CloneVM in vApp?

$
0
0

Hi,

 

I have a working script that I want to use with vApps.  But when I create linked clones, I cannot figure out what 'folder' to specify (below):


functionnew-linkedClone() {
    param(
            [Parameter(Position=0, Mandatory=$true)]
            [string]$sourceName,
            [Parameter(Position=1, Mandatory=$true)]
            [string]$cloneName,
            [Parameter(Position=2, Mandatory=$true)]
            [xml]$globals
         )

    $customSpec = $globals.clones.spec

    $tcagentsetup = [bool](($xmlData.clones.teamcityAgent).tolower() -eq'true')
    $script:startTime = get-date

    write-host"source: ${sourceName} clone: ${cloneName} spec: ${customSpec}"

    $customDoneStub = "Customization of VM {0} succeeded"
    $customDone = ($customDoneStub -f$cloneName)

    $vmView = (Get-VM$sourceName | Get-View)
    $datastore = $vmView.Config.DatastoreUrl.Name

    <# What should this be for a vApp???  #>
    $cloneFolder = $vmView.parent

    $cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
    $cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
    $cloneSpec.Snapshot = $vmView.Snapshot.CurrentSnapshot
    $dmt = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking
    $cloneSpec.Location.DiskMoveType = $dmt
    $cloneSpec.Customization = (Get-OSCustomizationSpec -Name $customSpec).ExtensionData.Spec

    write-Host"Generating linked clone ${cloneName}"
    $vmView.CloneVM( $cloneFolder, $cloneName, $cloneSpec)
    <#               ^^^^^^^^^^^^
    Will not work for vApp. What to do?
    #>

    <# snip #>
}



Viewing all articles
Browse latest Browse all 201333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>