Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure vApp #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion vsphere-6.5-vghetto-standard-lab-deployment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ if($DeploymentTarget -eq "ESXI") {
}
}
$cluster = Get-Cluster -Server $viConnection -Name $VMCluster
# Cancel all vApp operations if the target Cluster is NOT DRS enabled
if (!$cluster.DrsEnabled) { $moveVMsIntovApp = 0 }
$datacenter = $cluster | Get-Datacenter
$vmhost = $cluster | Get-VMHost | Select -First 1

Expand Down Expand Up @@ -795,6 +797,36 @@ if($moveVMsIntovApp -eq 1 -and $DeploymentTarget -eq "VCENTER") {
My-Logger "Moving $NSXDisplayName into $VAppName vApp ..."
Move-VM -VM $nsxVM -Server $viConnection -Destination $VApp -Confirm:$false | Out-File -Append -LiteralPath $verboseLogFile
}

My-Logger "Configuring vApp $VAppName ..."
### Create vApp Config specification ###
$vAppSpec = New-Object VMware.Vim.VAppConfigSpec
### Set vApp Start Order [$vAppSpec.EntityConfig] ###
$VApp.ExtensionData.VAppConfig.EntityConfig | % {
if ($NestedESXiHostnameToIPs.GetEnumerator().Name -contains $_.Tag)
{
$Keys = (($_ | Get-Member -MemberType Property).Where{ $_.Definition -match ';set' }).Name
$specEntity = New-Object VMware.Vim.VAppEntityConfigInfo
foreach ($Key in $Keys) { $specEntity.$Key = $_.$Key }
$specEntity.StartOrder = 1
$vAppSpec.EntityConfig += $specEntity
}
}
### Set vApp Product Info [$vAppSpec.Product] ###
$specProductInfo = New-Object VMware.Vim.VAppProductInfo
$specProductInfo.Name = "$deploymentType Nested ESXi Lab deployment"
$specProductInfo.Vendor = 'virtuallyGhetto'
$specProductInfo.Version = $vSphereVersion
$specProductInfo.FullVersion = Split-Path $NestedESXiApplianceOVA -Leaf
$specProductInfo.VendorUrl = 'https://www.virtuallyghetto.com'
$specProductInfo.ProductUrl = 'https://www.virtuallyghetto.com/2016/11/esxi-6-5-virtual-appliance-is-now-available.html'
$specProductInfo.AppUrl = 'https://github.com/lamw/vghetto-vsphere-automated-lab-deployment'
$specProduct = New-Object VMware.Vim.VAppProductSpec
$specProduct.Info = $specProductInfo
$specProduct.Operation = 'add'
$vAppSpec.Product = $specProduct
### Apply vApp settings ###
$VApp.ExtensionData.UpdateVAppConfig($vAppSpec)
}

My-Logger "Disconnecting from $VIServer ..."
Expand Down Expand Up @@ -921,4 +953,4 @@ $duration = [math]::Round((New-TimeSpan -Start $StartTime -End $EndTime).TotalMi
My-Logger "vSphere $vSphereVersion Lab Deployment Complete!"
My-Logger "StartTime: $StartTime"
My-Logger " EndTime: $EndTime"
My-Logger " Duration: $duration minutes"
My-Logger " Duration: $duration minutes"