Add fixes for Linux environment and add Windows environment
This commit is contained in:
@@ -7,14 +7,14 @@ $ServerTemplateName Template VM used for server and router clones.
|
||||
$GuiTemplateName Template VM used for workstation clones.
|
||||
|
||||
This script expects these port groups to already exist:
|
||||
HQ-SERVER-Linux
|
||||
HQ-DMZ-Linux
|
||||
HQ-CLIENT-Linux
|
||||
INET-HQ-Linux
|
||||
INET-BRANCH-Linux
|
||||
HOME-Linux
|
||||
BR-SERVER-Linux
|
||||
BR-CLIENT-Linux
|
||||
PG-VLAN10 (HQ-SERVER)
|
||||
PG-VLAN11 (HQ-DMZ)
|
||||
PG-VLAN12 (HQ-CLIENT)
|
||||
PG-VLAN20 (INET-HQ)
|
||||
PG-VLAN21 (INET-BRANCH)
|
||||
PG-VLAN23 (HOME)
|
||||
PG-VLAN30 (BR-SERVER)
|
||||
PG-VLAN51 (BR-CLIENT)
|
||||
|
||||
What the script does:
|
||||
- Creates the ES2025 Linux topology VMs as linked clones
|
||||
@@ -33,9 +33,11 @@ param()
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$TemplateFolderName = 'Templates'
|
||||
$TargetParentFolderName = 'Euroskills 2025'
|
||||
$TargetFolderName = 'Linux'
|
||||
$DatacenterName = 'Ilica'
|
||||
$TemplateFolderName = 'Templates'
|
||||
$SkillsFolderName = 'Skills'
|
||||
$TargetParentFolderName = 'ES2025'
|
||||
$TargetFolderName = 'Linux'
|
||||
$ServerTemplateName = 'debian-13-template'
|
||||
$GuiTemplateName = 'debian-13-gui-template'
|
||||
$ReferenceSnapshotName = 'start'
|
||||
@@ -51,10 +53,14 @@ $CloudInitShutdownTimeoutSeconds = 900
|
||||
function Get-SingleFolder {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name
|
||||
[string]$Name,
|
||||
|
||||
$Location = $null
|
||||
)
|
||||
|
||||
$folders = @(Get-Folder -Name $Name -ErrorAction SilentlyContinue)
|
||||
$params = @{ Name = $Name; Type = 'VM'; ErrorAction = 'SilentlyContinue' }
|
||||
if ($Location) { $params['Location'] = $Location }
|
||||
$folders = @(Get-Folder @params)
|
||||
|
||||
if ($folders.Count -eq 0) {
|
||||
throw "Folder '$Name' was not found."
|
||||
@@ -76,7 +82,7 @@ function Get-SingleChildFolder {
|
||||
$ParentFolder
|
||||
)
|
||||
|
||||
$folders = @(Get-Folder -Location $ParentFolder -Name $Name -ErrorAction SilentlyContinue)
|
||||
$folders = @(Get-Folder -Location $ParentFolder -Name $Name -Type VM -ErrorAction SilentlyContinue)
|
||||
|
||||
if ($folders.Count -eq 0) {
|
||||
throw "Folder '$Name' was not found under '$($ParentFolder.Name)'."
|
||||
@@ -280,9 +286,11 @@ function Wait-ForVmToPowerOff {
|
||||
throw "VM '$($VM.Name)' did not power off within $TimeoutSeconds seconds."
|
||||
}
|
||||
|
||||
$templateFolder = Get-SingleFolder -Name $TemplateFolderName
|
||||
$targetParentFolder = Get-SingleFolder -Name $TargetParentFolderName
|
||||
$targetFolder = Get-SingleChildFolder -Name $TargetFolderName -ParentFolder $targetParentFolder
|
||||
$datacenter = Get-Datacenter -Name $DatacenterName -ErrorAction Stop
|
||||
$skillsFolder = Get-SingleFolder -Name $SkillsFolderName -Location $datacenter
|
||||
$templateFolder = Get-SingleChildFolder -Name $TemplateFolderName -ParentFolder $skillsFolder
|
||||
$targetParentFolder = Get-SingleChildFolder -Name $TargetParentFolderName -ParentFolder $skillsFolder
|
||||
$targetFolder = Get-SingleChildFolder -Name $TargetFolderName -ParentFolder $targetParentFolder
|
||||
|
||||
$serverTemplate = Get-SingleVmFromFolder -Name $ServerTemplateName -Folder $templateFolder
|
||||
$guiTemplate = Get-SingleVmFromFolder -Name $GuiTemplateName -Folder $templateFolder
|
||||
@@ -291,18 +299,18 @@ $serverReferenceSnapshot = Get-OrCreateReferenceSnapshot -VM $serverTemplate -Sn
|
||||
$guiReferenceSnapshot = Get-OrCreateReferenceSnapshot -VM $guiTemplate -SnapshotName $ReferenceSnapshotName
|
||||
|
||||
$vmDefinitions = @(
|
||||
@{ Name = 'R-HQ'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-SERVER-Linux', 'HQ-DMZ-Linux', 'HQ-CLIENT-Linux', 'INET-HQ-Linux') },
|
||||
@{ Name = 'R-INT'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('INET-HQ-Linux', 'INET-BRANCH-Linux', 'HOME-Linux') },
|
||||
@{ Name = 'R-BR'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('BR-SERVER-Linux', 'BR-CLIENT-Linux', 'INET-BRANCH-Linux') },
|
||||
@{ Name = 'HQ-DC'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-SERVER-Linux') },
|
||||
@{ Name = 'HQ-SAM-1'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-SERVER-Linux') },
|
||||
@{ Name = 'HQ-SAM-2'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-SERVER-Linux') },
|
||||
@{ Name = 'HQ-DMZ-1'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-DMZ-Linux') },
|
||||
@{ Name = 'HQ-DMZ-2'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('HQ-DMZ-Linux') },
|
||||
@{ Name = 'BR-SRV'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('BR-SERVER-Linux') },
|
||||
@{ Name = 'HQ-CL'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('HQ-CLIENT-Linux') },
|
||||
@{ Name = 'HOME'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('HOME-Linux') },
|
||||
@{ Name = 'BR-CL'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('BR-CLIENT-Linux') }
|
||||
@{ Name = 'R-HQ'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN10', 'PG-VLAN11', 'PG-VLAN12', 'PG-VLAN20') },
|
||||
@{ Name = 'R-INT'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN20', 'PG-VLAN21', 'PG-VLAN23') },
|
||||
@{ Name = 'R-BR'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN30', 'PG-VLAN51', 'PG-VLAN21') },
|
||||
@{ Name = 'HQ-DC'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN10') },
|
||||
@{ Name = 'HQ-SAM-1'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN10') },
|
||||
@{ Name = 'HQ-SAM-2'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN10') },
|
||||
@{ Name = 'HQ-DMZ-1'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN11') },
|
||||
@{ Name = 'HQ-DMZ-2'; Template = $serverTemplate; Snapshot = $serverReferenceSnapshot; Networks = @('PG-VLAN11') },
|
||||
@{ Name = 'BR-SRV'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('PG-VLAN30') },
|
||||
@{ Name = 'HQ-CL'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('PG-VLAN12') },
|
||||
@{ Name = 'HOME'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('PG-VLAN23') },
|
||||
@{ Name = 'BR-CL'; Template = $guiTemplate; Snapshot = $guiReferenceSnapshot; Networks = @('PG-VLAN51') }
|
||||
)
|
||||
|
||||
foreach ($definition in $vmDefinitions) {
|
||||
@@ -332,6 +340,11 @@ foreach ($definition in $vmDefinitions) {
|
||||
Ensure-ExtraDisks -VM $vm -DiskCount $ExtraDiskCount -DiskSizeGB $ExtraDiskSizeGB
|
||||
Set-ExactNetworkAdapters -VM $vm -PortGroupNames $definition.Networks
|
||||
Set-CloudInitUserData -VM $vm -Username $DefaultUsername -Password $DefaultPassword
|
||||
$templateCdroms = @(Get-CDDrive -VM $definition.Template | Sort-Object Name)
|
||||
$vmCdroms = @(Get-CDDrive -VM $vm | Sort-Object Name)
|
||||
for ($i = 0; $i -lt $templateCdroms.Count; $i++) {
|
||||
$vmCdroms[$i] | Set-CDDrive -IsoPath $templateCdroms[$i].IsoPath -StartConnected $true -Confirm:$false | Out-Null
|
||||
}
|
||||
|
||||
$startSnapshot = Get-Snapshot -VM $vm -Name $StartSnapshotName -ErrorAction SilentlyContinue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user