VMware Script - Script to Clone vAPP
In this post I bring a script that will help you clone vAPP using powercli and can be improved and placed in the VRO.
I hope it helps and I left your comment or doubt, which I will respond as soon as possible.
### Script in get-view for clone virtualApps ###
# Mob reference you need to access /mob/ rootFolder > ManagedObjectReference:Datacenter > ManagedObjectReference:Folder > ManagedObjectReference:ManagedEntity[] #
#---------------CloneVApp_Task---------------
$name = 'app-new-vro-powercli-v2' #Specify a vAPP New Name
$target = New-Object VMware.Vim.ManagedObjectReference
$target.Type = 'ResourcePool'
$target.Value = 'resgroup-9' #Get resoruce pool name by vCenter/Mob
$spec = New-Object VMware.Vim.VAppCloneSpec
$spec.NetworkMapping = New-Object VMware.Vim.VAppCloneSpecNetworkMappingPair[] (1)
$spec.NetworkMapping[0] = New-Object VMware.Vim.VAppCloneSpecNetworkMappingPair
$spec.NetworkMapping[0].Destination = New-Object VMware.Vim.ManagedObjectReference
$spec.NetworkMapping[0].Destination.Type = 'DistributedVirtualPortgroup'
$spec.NetworkMapping[0].Destination.Value = 'dvportgroup-27' #Specify Porgroup Destination - - Get this information by vCenter/Mob
$spec.NetworkMapping[0].Source = New-Object VMware.Vim.ManagedObjectReference
$spec.NetworkMapping[0].Source.Type = 'DistributedVirtualPortgroup'
$spec.NetworkMapping[0].Source.Value = 'dvportgroup-27' #Specify Porgroup Source - Get this information by vCenter/Mob
$spec.VmFolder = New-Object VMware.Vim.ManagedObjectReference
$spec.VmFolder.Type = 'Folder'
$spec.VmFolder.Value = 'group-v4' #Specify VM Folder - Get this information by vCenter/Mob
$spec.Host = New-Object VMware.Vim.ManagedObjectReference
$spec.Host.Type = 'HostSystem'
$spec.Host.Value = 'host-14' #Specify Host ESXI - Get this Information by vCenter/Mob
$spec.Location = New-Object VMware.Vim.ManagedObjectReference
$spec.Location.Type = 'Datastore'
$spec.Location.Value = 'datastore-19' #Specify Datastore - Get datastore by vCenter/Mob
$spec.Provisioning = 'thin'
$spec.ResourceSpec = New-Object VMware.Vim.ResourceConfigSpec
$spec.ResourceSpec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.ResourceSpec.MemoryAllocation.Shares = New-Object VMware.Vim.SharesInfo
$spec.ResourceSpec.MemoryAllocation.Shares.Shares = 163840 #Set memory size
$spec.ResourceSpec.MemoryAllocation.Shares.Level = 'normal'
$spec.ResourceSpec.MemoryAllocation.Limit = -1
$spec.ResourceSpec.MemoryAllocation.Reservation = 0
$spec.ResourceSpec.MemoryAllocation.ExpandableReservation = $true
$spec.ResourceSpec.ScaleDescendantsShares = 'disabled'
$spec.ResourceSpec.CpuAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.ResourceSpec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo
$spec.ResourceSpec.CpuAllocation.Shares.Shares = 4000 #Set vCPU Size
$spec.ResourceSpec.CpuAllocation.Shares.Level = 'normal'
$spec.ResourceSpec.CpuAllocation.Limit = -1
$spec.ResourceSpec.CpuAllocation.Reservation = 0
$spec.ResourceSpec.CpuAllocation.ExpandableReservation = $true
$_this = Get-View -Id 'VirtualApp-resgroup-v1001' #Get VIrtualApp ID by MOB
# You could duplicate this Script by vApp
#-------- Starting--------#
$_this.CloneVApp_Task($name, $target, $spec)
Nenhum comentário:
Postar um comentário