Skip to content

Commit 136b8c8

Browse files
Merge pull request #9912 from vr4manta/SPLAT-2463
SPLAT-2463: Added ability to configure CoresPerSocket
2 parents d0aabcc + 7e8ad3b commit 136b8c8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

upi/vsphere/powercli/upi-functions.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
function 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

upi/vsphere/powercli/upi.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ $template = Get-VM -Server $fds[0].server -Name $vm_template -Location $fds[0].d
263263
# Create LB for Cluster
264264
$ignition = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((New-LoadBalancerIgnition $sshKey)))
265265
$network = New-VMNetworkConfig -Server $fds[0].server -Hostname "$($metadata.infraID)-lb" -IPAddress $lb_ip_address -Netmask $netmask -Gateway $gateway -DNS $dns -Network $failure_domains[0].network
266-
$vm = New-OpenShiftVM -IgnitionData $ignition -Name "$($metadata.infraID)-lb" -Template $template -Server $fds[0].server -ResourcePool $rp -Datastore $datastoreInfo -Location $folder -Tag $tag -Networking $network -Network $($fds[0].network) -SecureBoot $secureboot -StoragePolicy $storagepolicy -MemoryMB 8192 -NumCpu 4
266+
$vm = New-OpenShiftVM -IgnitionData $ignition -Name "$($metadata.infraID)-lb" -Template $template -Server $fds[0].server -ResourcePool $rp -Datastore $datastoreInfo -Location $folder -Tag $tag -Networking $network -Network $($fds[0].network) -SecureBoot $secureboot -StoragePolicy $storagepolicy -MemoryMB 8192 -NumCpu 4 -CoresPerSocket 4
267267
$vm | Start-VM
268268

269269
# Take the $virtualmachines defined in upi-variables and convert to a powershell object

0 commit comments

Comments
 (0)