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

vcsim: propagate CustomizeVM MacAddress to Virtual NIC #2511

Merged
merged 1 commit into from Jul 15, 2021

Conversation

dougm
Copy link
Member

@dougm dougm commented Jul 7, 2021

Description

The object.VirtualMachine.WaitForNetIP method depends on both the Virtual NIC's MacAddress and
the MacAddress reported by vmware-tools (guest.net[].macaddress property).

With this we can enable WaitForNetIP testing (govc vm.ip) against vcsim.

Related: #2510

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

vm.ip bats test enabled against vcsim

Checklist:

  • My code follows the CONTRIBUTION guidelines of
    this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

The object.VirtualMachine.WaitForNetIP method depends on both the Virtual NIC's MacAddress and
the MacAddress reported by vmware-tools (guest.net[].macaddress property).

With this we can enable WaitForNetIP testing (govc vm.ip) against vcsim.
for i, s := range vm.imc.NicSettingMap {
nic := &vm.Guest.Net[i]
if s.MacAddress != "" {
nic.MacAddress = s.MacAddress
nic.MacAddress = strings.ToLower(s.MacAddress) // MacAddress in guest will always be lowercase
card := cards[i].(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cards slice would always match the number of NIC mappings, i.e. nil pointer exception or cards to settings mismatch would never occur correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we validate the length as part of CustomizeVM here:

if len(vm.Guest.Net) != len(req.Spec.NicSettingMap) {
return nil, &types.NicSettingMismatch{
NumberOfNicsInSpec: int32(len(req.Spec.NicSettingMap)),
NumberOfNicsInVM: int32(len(vm.Guest.Net)),
}
}

Copy link
Contributor

@embano1 embano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my delayed response Doug. Approving the PR just one minor question to clarify nil semantics.

@dougm dougm merged commit 7822b34 into vmware:master Jul 15, 2021
@dougm dougm deleted the vcsim-waitnetip branch July 15, 2021 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants