VMware Cloud Community
dwchan
Enthusiast
Enthusiast

Set default VLAN ID on OVA/OVF

I am deploying Nested ESX on a group of ESX hosts with DVS switch.  I have a portgroup on the DVS that is trunk, the nested ESX OVA will be using the trunk portgroup for all of its vmnic.  I am able to do most of its initial configuration (99%) using the following

$ovfconfig = Get-OvfConfiguration $NestedESXiApplianceOVA
$networkMapLabel = ($ovfconfig.ToHashTable().keys | where {$_ -Match "NetworkMapping"}).replace("NetworkMapping.","").replace("-","_").replace(" ","_")
$ovfconfig.NetworkMapping.$networkMapLabel.value = $VLANTrunkPortgroup
$ovfconfig.common.guestinfo.hostname.value = $Nested_Hostname
$ovfconfig.common.guestinfo.ipaddress.value = $Nested_IP
$ovfconfig.common.guestinfo.netmask.value = $Nested_Subnet
$ovfconfig.common.guestinfo.gateway.value = $Nested_GW
$ovfconfig.common.guestinfo.dns.value = $Nested_DNS1 # $VMDNS
$ovfconfig.common.guestinfo.domain.value = $Nested_Domain
$ovfconfig.common.guestinfo.ntp.value = $VMNTP
$ovfconfig.common.guestinfo.syslog.value = $VMSyslog
$ovfconfig.common.guestinfo.password.value = $Nested_PW
$ovfconfig.common.guestinfo.ssh.value = $VCSASSHEnable

$orignalExtraConfig = $vm.ExtensionData.Config.ExtraConfig
$a = New-Object VMware.Vim.OptionValue
$a.key = "ethernet2.filter4.name"
$a.value = "dvfilter-maclearn"
$b = New-Object VMware.Vim.OptionValue
$b.key = "ethernet2.filter4.onFailure"
$b.value = "failOpen"
$c = New-Object VMware.Vim.OptionValue
$c.key = "ethernet3.filter4.name"
$c.value = "dvfilter-maclearn"
$d = New-Object VMware.Vim.OptionValue
$d.key = "ethernet3.filter4.onFailure"
$d.value = "failOpen"
$e = New-Object VMware.Vim.OptionValue
$e.key = "DefaultPortConfig.Vlan"
$e.value = "111"
$orignalExtraConfig+=$a
$orignalExtraConfig+=$b
$orignalExtraConfig+=$c
$orignalExtraConfig+=$d
$orignalExtraConfig+=$e

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ExtraConfig = $orignalExtraConfig

My-Logger "Adding guestinfo customization properties to '$Nested_Hostname' ..."
$task = $vm.ExtensionData.ReconfigVM_Task($spec)
$task1 = Get-Task -Id ("Task-$($task.value)")
$task1 | Wait-Task | Out-Null

However, what is the proper syntax/path using the $ovfconfig method to set my VLAN ID on my management port?  I need to set this to 110 as the physical ESX portgroup is trunk

dwchan_0-1614746263400.png

I tried 

$e = New-Object VMware.Vim.OptionValue
$e.key = "DefaultPortConfig.Vlan"
$e.value = "111"

and

$e = New-Object VMware.Vim.OptionValue
$e.key = "DefaultPortConfig.Vlan.VlanID"
$e.value = "111"

Without success.  I know I am close, just not sure what's the proper key/path to use.

 

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

Which OVA file do you mean?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

It is an OVA created by William LAM, here are the OVA link

Given I have never created an OVA just consume it, the options related to $ovfconfig setting, is this driven by some ovf configuration one created?  Or is there a universal standard (setting mapping) that everyone obey by?

dwc

Reply
0 Kudos
LucD
Leadership
Leadership

The one who creates the OVF decides what properties are present and exposed.

Isn't the VlanId in the Common.guestinfo.vlan property?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

dwchan
Enthusiast
Enthusiast

Let me take a look  is "common.guestinfo.vlan" a valid path?

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

Sweet, not sure if "common.guestinfo.vlan.value" is a common value that is available with most OVF, but it is enable 😉  Once I include this, it works.  Is any documentation as to all the possible expose path/value that are set up OVF/OVA?

Reply
0 Kudos
LucD
Leadership
Leadership

The ovftool documentation contains quite some info.

And of course the Get-OvfConfiguration cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dwchan
Enthusiast
Enthusiast

Did review the OVF tools doc awhile back, pretty sparse but is a start.  Thank you again for the help

Reply
0 Kudos