diff --git a/images.CI/macos/azure-pipelines/image-generation.yml b/images.CI/macos/azure-pipelines/image-generation.yml index 2663e1a83..1615116e7 100644 --- a/images.CI/macos/azure-pipelines/image-generation.yml +++ b/images.CI/macos/azure-pipelines/image-generation.yml @@ -132,6 +132,9 @@ jobs: -VIServer "$(vcenter-server-v2)" ` -VIUserName "$(vcenter-username-v2)" ` -VIPassword "$(vcenter-password-v2)" + -CpuCount "$(cpu-count)" ` + -CoresPerSocketCount "$(cores-per-socket-count)" ` + -Memory "$(memory)" - task: PowerShell@2 displayName: 'Destroy VM (if build canceled only)' diff --git a/images.CI/macos/move-vm.ps1 b/images.CI/macos/move-vm.ps1 index d94139877..f44f689c4 100644 --- a/images.CI/macos/move-vm.ps1 +++ b/images.CI/macos/move-vm.ps1 @@ -39,7 +39,13 @@ param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] - [string]$VIPassword + [string]$VIPassword, + + [int32]$CpuCount, + + [int32]$CoresPerSocketCount, + + [int64]$Memory ) # Import helpers module @@ -57,6 +63,11 @@ try { $vm = Get-VM $VMName +if ($VMName -notmatch "10.13") { + Write-Host "Change cpu count $cpu, cores count to $cores, amount of RAM to $memoryMb" + $vm | Set-VM -NumCPU $CpuCount -CoresPerSocket $CoresPerSocketCount -MemoryMB $Memory -Confirm:$false +} + if ($env:AGENT_JOBSTATUS -eq 'Failed') { try { if($vm.PowerState -ne "PoweredOff") { diff --git a/images.CI/macos/select-datastore.ps1 b/images.CI/macos/select-datastore.ps1 index 68bf4d9d3..4714bb6d3 100644 --- a/images.CI/macos/select-datastore.ps1 +++ b/images.CI/macos/select-datastore.ps1 @@ -54,14 +54,19 @@ function Select-DataStore { # 1. Name starts with ds-local-Datastore # 2. FreespaceGB > 400 Gb - # 3. VM count on a datastore < 2 + # 3. Choose a datastore with the minimal VM count < 2 Write-Host "Start Datastore selection process..." $allDatastores = Get-Datastore -Name $templateDatastore | Where-Object { $_.State -eq "Available" } - $buildDatastore = $allDatastores | Where-Object { $_.FreeSpaceGB -ge $thresholdInGb } | Where-Object { + $buildDatastore = $allDatastores ` + | Where-Object { $_.FreeSpaceGB -ge $thresholdInGb } ` + | Where-Object { $vmOnDatastore = @((Get-ChildItem -Path $_.DatastoreBrowserPath).Name -notmatch "^\.").Count - $vmOnDatastore -lt $vmCount - } | Get-Random | Select-Object -ExpandProperty Name + $vmOnDatastore -lt $vmCount } ` + | Group-Object -Property { $vmOnDatastore } ` + | Select-Object -First 1 -ExpandProperty Group ` + | Get-Random ` + | Select-Object -ExpandProperty Name $tag = Get-Tag -Category $TagCategory -Name $VMName -ErrorAction Ignore if (-not $tag) diff --git a/images/macos/templates/macOS-10.14.json b/images/macos/templates/macOS-10.14.json index 628b47745..35c04d76d 100644 --- a/images/macos/templates/macOS-10.14.json +++ b/images/macos/templates/macOS-10.14.json @@ -30,8 +30,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "4", - "RAM": "12288", + "CPUs": "10", + "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m" } diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 8dae77cab..575f109f4 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -30,8 +30,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "4", - "RAM": "12288", + "CPUs": "10", + "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m" } diff --git a/images/macos/templates/macOS-11.0.json b/images/macos/templates/macOS-11.0.json index c3d898c0d..943e53d16 100644 --- a/images/macos/templates/macOS-11.0.json +++ b/images/macos/templates/macOS-11.0.json @@ -30,8 +30,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "4", - "RAM": "12288", + "CPUs": "10", + "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m" }