diff --git a/images.CI/macos/azure-pipelines/image-generation.yml b/images.CI/macos/azure-pipelines/image-generation.yml index 8c53af41..65483279 100644 --- a/images.CI/macos/azure-pipelines/image-generation.yml +++ b/images.CI/macos/azure-pipelines/image-generation.yml @@ -55,7 +55,8 @@ jobs: arguments: -VMName "$(VirtualMachineName)" ` -VIServer "$(vcenter-server-v2)" ` -VIUserName "$(vcenter-username-v2)" ` - -VIPassword "$(vcenter-password-v2)" + -VIPassword '$(vcenter-password-v2)' ` + -Cluster "$(esxi-cluster-v2)" - pwsh: | $SensitiveData = @( @@ -66,13 +67,14 @@ jobs: packer build -on-error=abort ` -var="vcenter_server=$(vcenter-server-v2)" ` -var="vcenter_username=$(vcenter-username-v2)" ` - -var="vcenter_password=$(vcenter-password-v2)" ` + -var='vcenter_password=$(vcenter-password-v2)' ` -var="vcenter_datacenter=$(vcenter-datacenter-v2)" ` -var="cluster_or_esxi_host=$(esxi-cluster-v2)" ` -var="esxi_datastore=$(buildDatastore)" ` -var="output_folder=$(output-folder)" ` -var="vm_username=$(vm-username)" ` -var="vm_password=$(vm-password)" ` + -var="github_api_pat=$(github_api_pat)" ` -var="build_id=$(VirtualMachineName)" ` -var="baseimage_name=${{ parameters.base_image_name }}" ` -var="xcode_install_user=$(xcode-installation-user)" ` @@ -130,7 +132,7 @@ jobs: -TargetDataStore "${{ parameters.target_datastore }}" ` -VIServer "$(vcenter-server-v2)" ` -VIUserName "$(vcenter-username-v2)" ` - -VIPassword "$(vcenter-password-v2)" + -VIPassword '$(vcenter-password-v2)' ` -CpuCount "$(cpu-count)" ` -CoresPerSocketCount "$(cores-per-socket-count)" ` -Memory "$(memory)" @@ -144,4 +146,4 @@ jobs: arguments: -VMName "$(VirtualMachineName)" ` -VIServer "$(vcenter-server-v2)" ` -VIUserName "$(vcenter-username-v2)" ` - -VIPassword "$(vcenter-password-v2)" + -VIPassword '$(vcenter-password-v2)' diff --git a/images.CI/macos/select-datastore.ps1 b/images.CI/macos/select-datastore.ps1 index 1d9a898a..23b5fb5a 100644 --- a/images.CI/macos/select-datastore.ps1 +++ b/images.CI/macos/select-datastore.ps1 @@ -36,7 +36,9 @@ param( [ValidateNotNullOrEmpty()] [string]$VIPassword, - [string]$TagCategory = "Busy" + [string]$TagCategory = "Busy", + + [string]$Cluster ) # Import helpers module @@ -47,6 +49,7 @@ function Select-DataStore { [string]$VMName, [string]$TagCategory, [string]$TemplateDatastore = "ds-local-Datastore-*", + [string]$Cluster, [int]$ThresholdInGb = 400, [int]$VMCount = 2, [int]$Retries = 5 @@ -57,8 +60,9 @@ function Select-DataStore { # 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" } - $availableDatastores = $allDatastores ` + $clusterHosts = Get-Cluster -Name $Cluster | Get-VMHost + $availableClusterDatastores = $clusterHosts | Get-Datastore -Name $TemplateDatastore | Where-Object -Property State -eq "Available" + $availableDatastores = $availableClusterDatastores ` | Where-Object { $_.FreeSpaceGB -ge $thresholdInGb } ` | Where-Object { $vmOnDatastore = @((Get-ChildItem -Path $_.DatastoreBrowserPath).Name -notmatch "^\.").Count @@ -101,11 +105,11 @@ function Select-DataStore { } Write-Host "Datastore select failed, $retries left" - Select-DataStore -VMName $VMName -TagCategory $TagCategory -Retries $retries + Select-DataStore -VMName $VMName -Cluster $Cluster -TagCategory $TagCategory -Retries $retries } # Connection to a vCenter Server system Connect-VCServer -VIServer $VIServer -VIUserName $VIUserName -VIPassword $VIPassword # Get a target datastore for current deployment -Select-DataStore -VMName $VMName -TagCategory $TagCategory +Select-DataStore -VMName $VMName -Cluster $Cluster -TagCategory $TagCategory diff --git a/images/macos/templates/macOS-10.15.json b/images/macos/templates/macOS-10.15.json index 4edf744a..c55bb3f5 100644 --- a/images/macos/templates/macOS-10.15.json +++ b/images/macos/templates/macOS-10.15.json @@ -31,7 +31,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "10", + "CPUs": "5", + "cpu_cores": "5", "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m" diff --git a/images/macos/templates/macOS-11.json b/images/macos/templates/macOS-11.json index 10046d35..082228f7 100644 --- a/images/macos/templates/macOS-11.json +++ b/images/macos/templates/macOS-11.json @@ -31,7 +31,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "10", + "CPUs": "5", + "cpu_cores": "5", "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m" diff --git a/images/macos/templates/macOS-12.json b/images/macos/templates/macOS-12.json index d79e86bc..b10aa4fa 100644 --- a/images/macos/templates/macOS-12.json +++ b/images/macos/templates/macOS-12.json @@ -31,7 +31,8 @@ "vm_name": "{{user `build_id`}}", "ssh_username": "{{user `vm_username`}}", "ssh_password": "{{user `vm_password`}}", - "CPUs": "10", + "CPUs": "5", + "cpu_cores": "5", "RAM": "24576", "NestedHV": "true", "shutdown_timeout": "15m"