mirror of
https://github.com/actions/runner-images.git
synced 2025-12-17 23:28:57 +00:00
[MacOS] Build VM packer spec changed (#2359)
* scheduling condition added and changed VMs specs for macos * typo * changed conditions order * fixed an error * added spec parameters that use pipeline variables values Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
This commit is contained in:
@@ -132,6 +132,9 @@ jobs:
|
|||||||
-VIServer "$(vcenter-server-v2)" `
|
-VIServer "$(vcenter-server-v2)" `
|
||||||
-VIUserName "$(vcenter-username-v2)" `
|
-VIUserName "$(vcenter-username-v2)" `
|
||||||
-VIPassword "$(vcenter-password-v2)"
|
-VIPassword "$(vcenter-password-v2)"
|
||||||
|
-CpuCount "$(cpu-count)" `
|
||||||
|
-CoresPerSocketCount "$(cores-per-socket-count)" `
|
||||||
|
-Memory "$(memory)"
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: 'Destroy VM (if build canceled only)'
|
displayName: 'Destroy VM (if build canceled only)'
|
||||||
|
|||||||
@@ -39,7 +39,13 @@ param(
|
|||||||
|
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$VIPassword
|
[string]$VIPassword,
|
||||||
|
|
||||||
|
[int32]$CpuCount,
|
||||||
|
|
||||||
|
[int32]$CoresPerSocketCount,
|
||||||
|
|
||||||
|
[int64]$Memory
|
||||||
)
|
)
|
||||||
|
|
||||||
# Import helpers module
|
# Import helpers module
|
||||||
@@ -57,6 +63,11 @@ try {
|
|||||||
|
|
||||||
$vm = Get-VM $VMName
|
$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') {
|
if ($env:AGENT_JOBSTATUS -eq 'Failed') {
|
||||||
try {
|
try {
|
||||||
if($vm.PowerState -ne "PoweredOff") {
|
if($vm.PowerState -ne "PoweredOff") {
|
||||||
|
|||||||
@@ -54,14 +54,19 @@ function Select-DataStore {
|
|||||||
|
|
||||||
# 1. Name starts with ds-local-Datastore
|
# 1. Name starts with ds-local-Datastore
|
||||||
# 2. FreespaceGB > 400 Gb
|
# 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..."
|
Write-Host "Start Datastore selection process..."
|
||||||
$allDatastores = Get-Datastore -Name $templateDatastore | Where-Object { $_.State -eq "Available" }
|
$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 = @((Get-ChildItem -Path $_.DatastoreBrowserPath).Name -notmatch "^\.").Count
|
||||||
$vmOnDatastore -lt $vmCount
|
$vmOnDatastore -lt $vmCount } `
|
||||||
} | Get-Random | Select-Object -ExpandProperty Name
|
| 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
|
$tag = Get-Tag -Category $TagCategory -Name $VMName -ErrorAction Ignore
|
||||||
if (-not $tag)
|
if (-not $tag)
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
"vm_name": "{{user `build_id`}}",
|
"vm_name": "{{user `build_id`}}",
|
||||||
"ssh_username": "{{user `vm_username`}}",
|
"ssh_username": "{{user `vm_username`}}",
|
||||||
"ssh_password": "{{user `vm_password`}}",
|
"ssh_password": "{{user `vm_password`}}",
|
||||||
"CPUs": "4",
|
"CPUs": "10",
|
||||||
"RAM": "12288",
|
"RAM": "24576",
|
||||||
"NestedHV": "true",
|
"NestedHV": "true",
|
||||||
"shutdown_timeout": "15m"
|
"shutdown_timeout": "15m"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
"vm_name": "{{user `build_id`}}",
|
"vm_name": "{{user `build_id`}}",
|
||||||
"ssh_username": "{{user `vm_username`}}",
|
"ssh_username": "{{user `vm_username`}}",
|
||||||
"ssh_password": "{{user `vm_password`}}",
|
"ssh_password": "{{user `vm_password`}}",
|
||||||
"CPUs": "4",
|
"CPUs": "10",
|
||||||
"RAM": "12288",
|
"RAM": "24576",
|
||||||
"NestedHV": "true",
|
"NestedHV": "true",
|
||||||
"shutdown_timeout": "15m"
|
"shutdown_timeout": "15m"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
"vm_name": "{{user `build_id`}}",
|
"vm_name": "{{user `build_id`}}",
|
||||||
"ssh_username": "{{user `vm_username`}}",
|
"ssh_username": "{{user `vm_username`}}",
|
||||||
"ssh_password": "{{user `vm_password`}}",
|
"ssh_password": "{{user `vm_password`}}",
|
||||||
"CPUs": "4",
|
"CPUs": "10",
|
||||||
"RAM": "12288",
|
"RAM": "24576",
|
||||||
"NestedHV": "true",
|
"NestedHV": "true",
|
||||||
"shutdown_timeout": "15m"
|
"shutdown_timeout": "15m"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user