Skip to content

Commit

Permalink
vcsim: add guest.net.ipConfig
Browse files Browse the repository at this point in the history
This is needed to support the VirtualMachine.WaitForNetIP helper against vcsim
  • Loading branch information
dougm committed Feb 1, 2023
1 parent 4136fd8 commit 997d9dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions govc/test/vcsim.bats
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ EOF
netip=$(govc object.collect -json -s vm/$vm guest.net | jq -r .[].Val.GuestNicInfo[].IpAddress[0])
[ "$netip" = "$ip" ]

run govc vm.ip $vm # covers VirtualMachine.WaitForIP
assert_success "$ip"

run govc vm.ip -a $vm # covers VirtualMachine.WaitForNetIP
assert_success "$ip"

run govc vm.ip -n ethernet-0 $vm # covers VirtualMachine.WaitForNetIP
assert_success "$ip"

run govc vm.power -s $vm
assert_success

Expand Down
14 changes: 14 additions & 0 deletions simulator/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ func (c *container) inspect(vm *VirtualMachine) error {
net := &vm.Guest.Net[0]
net.IpAddress = []string{s.IPAddress}
net.MacAddress = s.MacAddress
net.IpConfig = &types.NetIpConfigInfo{
IpAddress: []types.NetIpConfigInfoIpAddress{{
IpAddress: s.IPAddress,
PrefixLength: int32(s.IPPrefixLen),
State: string(types.NetIpConfigInfoIpAddressStatusPreferred),
}},
}
}

for _, d := range vm.Config.Hardware.Device {
if eth, ok := d.(types.BaseVirtualEthernetCard); ok {
eth.GetVirtualEthernetCard().MacAddress = s.MacAddress
break
}
}
}

Expand Down

0 comments on commit 997d9dd

Please sign in to comment.