Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$lab_id = $args[0]
$folder_name = "ol7-k8s-lab-" + (0 + $lab_id).ToString("00")
$folder = Get-Datacenter "infra-dc-01" | Get-Folder -Name "vm" | New-Folder -Name $folder_name
("k8s-m-" + $lab_id.ToString() + "1"),
("k8s-w-" + $lab_id.ToString() + "1"),
("k8s-w-" + $lab_id.ToString() + "2"),
("k8s-w-" + $lab_id.ToString() + "3")| % {
Get-VM "ol76-min-01" | New-VM -Name $_ `
-ResourcePool "rp-03-lab" `
-Location $folder `
-Datastore "vsanDatastore" -StorageFormat Thin `
-RunAsync
}
$clone_wait_interval = 10
$s = 0
while((Get-Task | where {$_.Name -eq "CloneVM_Task"} | where {$_.State -ne "Success"}).Count -ne 0){
$s += $clone_wait_interval
sleep $clone_wait_interval
echo ("clone wait: " + $s + "s")
}
$folder | Get-VM | Sort-Object Name | % {
$_ | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup "vxw-dvs-30-virtualwire-14-sid-10003-ls-lab-k8s-003" -Confirm:$false | ft -AutoSize
$_ | Set-VM -NumCpu 2 -MemoryGB 4 -Confirm:$false | ft -AutoSize
$_ | New-AdvancedSetting -Name disk.EnableUUID -Value True -Confirm:$False | ft -AutoSize
$_ | Start-VM
sleep 5
}
$vm_start_wait_sec = 60
"VM Start wait: " + $vm_start_wait_sec + "s"
sleep $vm_start_wait_sec
$folder | Get-VM | select `
Name,
PowerState,
NumCPU,
MemoryGB,
@{N="IP";E={$_.Guest.IPAddress | where {$_ -like "*.*"}}},
@{N="PG";E={($_|Get-NetworkAdapter).NetworkName}} |
Sort-Object Name | ft -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.