mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 22:26:56 +00:00
Separate VM resizing and moving into two different scripts (#7584)
This commit is contained in:
committed by
GitHub
parent
eb53372646
commit
4ca86478ee
73
images.CI/macos/set-vm-size.ps1
Normal file
73
images.CI/macos/set-vm-size.ps1
Normal file
@@ -0,0 +1,73 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
This script sets resources for VM
|
||||
|
||||
.PARAMETER VMName
|
||||
VM name to resize (Example "macOS-10.15_20201012.4")
|
||||
|
||||
.PARAMETER VIServer
|
||||
vCenter address (Example "10.0.1.16")
|
||||
|
||||
.PARAMETER VIUserName
|
||||
vCenter username (Example "Administrator")
|
||||
|
||||
.PARAMETER VIPassword
|
||||
vCenter password (Example "12345678")
|
||||
|
||||
.PARAMETER CpuCount
|
||||
Target number of CPUs (Example "3")
|
||||
|
||||
.PARAMETER CoresPerSocketCount
|
||||
Target number of cores per socket (Example "3")
|
||||
|
||||
.PARAMETER Memory
|
||||
Target amount of memory in MB (Example "14336")
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VMName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIServer,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIUserName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIPassword,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[int32]$CpuCount,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[int32]$CoresPerSocketCount,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[int64]$Memory
|
||||
)
|
||||
|
||||
# Import helpers module
|
||||
Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
||||
|
||||
# Connection to a vCenter Server system
|
||||
Connect-VCServer -VIServer $VIServer -VIUserName $VIUserName -VIPassword $VIPassword
|
||||
|
||||
$vm = Get-VM $VMName
|
||||
try {
|
||||
Write-Host "Change CPU count to $CpuCount, cores count to $CoresPerSocketCount, amount of RAM to $Memory"
|
||||
$vm | Set-VM -NumCPU $CpuCount -CoresPerSocket $CoresPerSocketCount -MemoryMB $Memory -Confirm:$false -ErrorAction Stop | Out-Null
|
||||
} catch {
|
||||
Write-Host "##vso[task.LogIssue type=error;]Failed to change specs for VM '$VMName'"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user