@@ -160,6 +160,16 @@ foreach ($fd in $fds)
160160 New-TagAssignment - Entity $folder - Tag $tag > $null
161161 }
162162
163+ # Create resource pool for all future VMs
164+ Write-Output " Checking for resource pool in failure domain $ ( $fd.datacenter ) /$ ( $fd.cluster ) "
165+ $rp = Get-ResourcePool - Name $ ($metadata.infraID ) - Location $ (Get-Cluster - Name $ ($fd.cluster )) - ErrorAction continue 2> $null
166+
167+ if (-Not $? ) {
168+ Write-Output " Creating resource pool $ ( $metadata.infraID ) in datacenter $ ( $fd.datacenter ) "
169+ $rp = New-ResourcePool - Name $ ($metadata.infraID ) - Location $ (Get-Cluster - Name $ ($fd.cluster ))
170+ New-TagAssignment - Entity $rp - Tag $tag > $null
171+ }
172+
163173 # If the rhcos virtual machine already exists
164174 Write-Output " Checking for vm template in failure domain $ ( $fd.datacenter ) /$ ( $fd.cluster ) "
165175 $template = Get-VM - Name $vm_template - Location $fd.datacenter - ErrorAction continue
@@ -215,7 +225,7 @@ if ($jobs.count -gt 0)
215225Write-Output " Creating LB"
216226
217227# Data needed for LB VM creation
218- $rp = Get-Cluster - Name $fds [0 ].cluster - Server $vcenter
228+ $rp = Get-ResourcePool - Name $ ( $metadata .infraID ) - Location $ ( Get- Cluster - Name $ ( $ fds [0 ].cluster)) - Server $vcenter
219229$datastoreInfo = Get-Datastore - Name $fds [0 ].datastore - Server $vcenter - Location $fds [0 ].datacenter
220230$folder = Get-Folder - Name $metadata.infraID - Location $fds [0 ].datacenter
221231$template = Get-VM - Name $vm_template - Location $fds [0 ].datacenter
@@ -250,7 +260,7 @@ foreach ($key in $vmHash.virtualmachines.Keys) {
250260 $name = " $ ( $metadata.infraID ) -$ ( $key ) "
251261 Write-Output " Creating $ ( $name ) "
252262
253- $rp = Get-Cluster - Name $node.cluster - Server $node .server
263+ $rp = Get-ResourcePool - Name $ ( $metadata .infraID ) - Location $ ( Get- Cluster - Name $ ( $ node.cluster )) - Server $vcenter
254264 # #$datastore = Get-Datastore -Name $node.datastore -Server $node.server
255265 $datastoreInfo = Get-Datastore - Name $node.datastore - Location $node.datacenter
256266
0 commit comments