mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-29 04:47:38 +08:00
[macOS] Switch image generation to faster datastores (#1801)
* select datastore script * add debug message * add move-vm and helpers * add error action * formatting the script * nits * add missing quotes * add synopsis
This commit is contained in:
59
images.CI/macos/move-vm.ps1
Normal file
59
images.CI/macos/move-vm.ps1
Normal file
@@ -0,0 +1,59 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
This script migrates given VM to another datastore
|
||||
|
||||
.PARAMETER VMName
|
||||
VM name to migrate (Example "macOS-10.15_20201012.4")
|
||||
|
||||
.PARAMETER TargetDataStore
|
||||
Target datastore (Example "ds-image")
|
||||
|
||||
.PARAMETER VIServer
|
||||
vCenter address (Example "10.0.1.16")
|
||||
|
||||
.PARAMETER VIUserName
|
||||
vCenter username (Example "Administrator")
|
||||
|
||||
.PARAMETER VIPassword
|
||||
vCenter password (Example "12345678")
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VMName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$TargetDataStore,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIServer,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIUserName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$VIPassword
|
||||
)
|
||||
|
||||
# Import helpers module
|
||||
Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
||||
|
||||
# Connection to a vCenter Server system
|
||||
Connect-VCServer
|
||||
|
||||
try
|
||||
{
|
||||
Get-VM $VMName | Move-VM -Datastore $TargetDataStore -ErrorAction Stop
|
||||
Write-Host "VM has been moved successfully to target datastore '$TargetDataStore'"
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
|
||||
}
|
||||
Reference in New Issue
Block a user