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: Sets "ChangeTrackingSupported" property of the simulated VM #2468

Merged

Conversation

amanpaha
Copy link
Contributor

Description

This change checks the device type and sets ChangeTrackingSupported property for the simulated VM accordingly.
Before enabling change tracking for VM, we validates if change tracking is supported or not by checking the Capability.ChangeTrackingSupported property. While writing unit test we are using vcsim for getting simulated VM but we cant test our functionality after checking ChangeTrackingSupported, since it is always nil.

How Has This Been Tested?

Ran virtual_machine_test.go (package simulator) to see if this property is populated or not.

@vmwclabot
Copy link
Member

@amanpaha, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction.

@embano1
Copy link
Contributor

embano1 commented May 27, 2021

Thank you @amanpaha for your contribution! I‘ll have @dougm do the code review, but could you please squash your commit? +1 for using the vcsim: prefix in the commit title.

@amanpaha amanpaha force-pushed the amanpaha/vcsim-changetrackingsupported branch from 36b652b to 7b961a8 Compare May 27, 2021 12:55
for _, device := range spec.DeviceChange {
if dev, ok := device.GetVirtualDeviceConfigSpec().Device.(*types.VirtualDisk); ok {

if _, ok := dev.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @amanpaha , your first commit used a switch dev.Backing.(type), which is what I would suggest here. I think changeTrackingSupported can return bool instead of *bool, then each case can return true and the default case return false. Then use the NewBool helper to convert to a pointer:

vm.Capability.ChangeTrackingSupported = types.NewBool(changeTrackingSupported(spec))

What do you think?

Copy link
Contributor Author

@amanpaha amanpaha May 28, 2021

Choose a reason for hiding this comment

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

Yes, definitely looks good now, thanks for the suggestion.
I have made the change, should I resolve the conversation or reviewer will do it after verifying that the correct changes were made.

changing swtich to if block

Reverting to switch block
@amanpaha amanpaha force-pushed the amanpaha/vcsim-changetrackingsupported branch from b3d7bd7 to 44ae85f Compare May 28, 2021 05:31
@vmwclabot
Copy link
Member

@amanpaha, VMware has approved your signed contributor license agreement.

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @amanpaha !

@dougm dougm merged commit df9dfde into vmware:master May 28, 2021
protochron pushed a commit to protochron/govmomi that referenced this pull request Aug 31, 2021
yuyin002 pushed a commit to yuyin002/govmomi that referenced this pull request Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants