22
33function New-OpenShiftVM {
44 param (
5+ [int ]$CoresPerSocket = 1 , # Default is 1 due to not knowing how many may come in via NumCpu variable
56 [Parameter (Mandatory = $true )]
67 $Datastore ,
78 [Parameter (Mandatory = $true )]
89 [string ]$IgnitionData ,
910 [switch ]$LinkedClone ,
1011 $Location ,
11- $MemoryMB ,
12+ [ int ] $MemoryMB = 8192 ,
1213 [Parameter (Mandatory = $true )]
1314 [string ]$Name ,
1415 $Network ,
1516 $Networking ,
16- $NumCpu ,
17+ [ int ] $NumCpu = 4 ,
1718 $ReferenceSnapshot ,
1819 $ResourcePool ,
1920 $SecureBoot ,
@@ -38,6 +39,7 @@ function New-OpenShiftVM {
3839 $args.Remove (' Network' ) > $null
3940 $args.Remove (' MemoryMB' ) > $null
4041 $args.Remove (' NumCpu' ) > $null
42+ $args.Remove (' CoresPerSocket' ) > $null
4143 $args.Remove (' SecureBoot' ) > $null
4244 foreach ($key in $args.Keys ){
4345 if ($NULL -eq $ ($args.Item ($key )) -or $ ($args.Item ($key )) -eq " " ) {
@@ -62,7 +64,7 @@ function New-OpenShiftVM {
6264 # Update VM specs. New-VM does not honor the passed in parameters due to Template being used.
6365 if ($null -ne $MemoryMB -And $null -ne $NumCpu )
6466 {
65- Set-VM - Server $Server - VM $vm - MemoryMB $MemoryMB - NumCpu $NumCpu - CoresPerSocket 4 - Confirm:$false > $null
67+ Set-VM - Server $Server - VM $vm - MemoryMB $MemoryMB - NumCpu $NumCpu - CoresPerSocket $CoresPerSocket - Confirm:$false > $null
6668 }
6769 # Get-HardDisk -VM $vm | Select-Object -First 1 | Set-HardDisk -CapacityGB 120 -Confirm:$false > $null
6870 updateDisk - VM $vm - CapacityGB 120
@@ -284,14 +286,23 @@ function New-OpenshiftVMs {
284286 if ($node.type -eq " master" ) {
285287 $numCPU = $control_plane_num_cpus
286288 $memory = $control_plane_memory
289+ $coresPerSocket = $control_plane_cores_per_socket
287290 } elseif ($node.type -eq " worker" ) {
288291 $numCPU = $compute_num_cpus
289292 $memory = $compute_memory
293+ $coresPerSocket = $compute_cores_per_socket
290294 } else {
291295 # should only be bootstrap
292296 $numCPU = $control_plane_num_cpus
293297 $memory = $control_plane_memory
298+ $coresPerSocket = $control_plane_cores_per_socket
294299 }
300+
301+ # Since coresPerSocket is not required for configs, we need to make sure its not zero (default). We'll make it match NumCPU.
302+ if ($NULL -eq $coresPerSocket -or $coresPerSocket -lt 1 ) {
303+ $coresPerSocket = $numCPU
304+ }
305+
295306 $ip = $node.ip
296307 $network = New-VMNetworkConfig - Server $node.server - Hostname $name - IPAddress $ip - Netmask $netmask - Gateway $gateway - DNS $dns
297308
@@ -309,7 +320,7 @@ function New-OpenshiftVMs {
309320
310321 # Clone the virtual machine from the imported template
311322 # $vm = New-OpenShiftVM -Template $template -Name $name -ResourcePool $rp -Datastore $datastoreInfo -Location $folder -LinkedClone -ReferenceSnapshot $snapshot -IgnitionData $ignition -Tag $tag -Networking $network -NumCPU $numCPU -MemoryMB $memory
312- $vm = New-OpenShiftVM - Server $node.server - Template $template - Name $name - ResourcePool $rp - Datastore $datastoreInfo - Location $folder - IgnitionData $ignition - Tag $tag - Networking $network - Network $node.network - SecureBoot $secureboot - StoragePolicy $storagepolicy - NumCPU $numCPU - MemoryMB $memory
323+ $vm = New-OpenShiftVM - Server $node.server - Template $template - Name $name - ResourcePool $rp - Datastore $datastoreInfo - Location $folder - IgnitionData $ignition - Tag $tag - Networking $network - Network $node.network - SecureBoot $secureboot - StoragePolicy $storagepolicy - NumCPU $numCPU - MemoryMB $memory - CoresPerSocket $coresPerSocket
313324
314325 # Assign tag so we can later clean up
315326 # New-TagAssignment -Entity $vm -Tag $tag
0 commit comments