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

Add govc snapshot size command, standalone SnapshotSize function #2269

Conversation

atc0005
Copy link
Contributor

@atc0005 atc0005 commented Feb 4, 2021

Add support for snapshot size calculations

  • govc: Add size (s) flag to snapshot.tree subcommand
  • Add object.SnapshotSize and helper functions
    to support calculating snapshot size from other
    client code

Credit to @dougm for providing successive code examples,
explanation and guidance for understanding the required
steps to implement this support.

As noted on GH-2243, code provided by @dougm was (AFAIK)
based heavily on existing C# code for PowerCLI
implementation of the Get-Snapshot cmdlet.

@atc0005
Copy link
Contributor Author

atc0005 commented Feb 4, 2021

@dougm Setting this as a draft since I've not squashed commits and finished cleaning up the branch yet.

What are your preferences regarding code comments? I assumed that the project style was to omit them unless necessary and have pruned the majority of them back. a54302c represents that state, except for a few lines I wanted to get your feedback on.

7dfb85b represents a version of the code with comments, but without the "note to self" verbosity that I used to begin with as I explored the code. Is this form useful?

govc/vm/snapshot/tree.go Outdated Show resolved Hide resolved
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.

Thanks @atc0005 !
Code comments are welcome, especially in this case where vSphere's own docs don't help much.

govc/vm/snapshot/size.go Outdated Show resolved Hide resolved
govc/vm/snapshot/size.go Outdated Show resolved Hide resolved
govc/vm/snapshot/tree.go Outdated Show resolved Hide resolved
@atc0005 atc0005 force-pushed the i2243-attempt-to-understand-snapshot-size-calc-logic branch from a54302c to 7de988e Compare February 12, 2021 12:09
@atc0005
Copy link
Contributor Author

atc0005 commented Feb 12, 2021

@dougm I've made a pass to incorporate suggested changes. I've added light doc comments to the functions themselves, but not to the function body. Are those welcome, or is it preferred to keep them specific to what godoc exposes?

@dougm
Copy link
Member

dougm commented Feb 15, 2021

@dougm I've made a pass to incorporate suggested changes. I've added light doc comments to the functions themselves, but not to the function body. Are those welcome, or is it preferred to keep them specific to what godoc exposes?

Thanks @atc0005 , looks great. In general, I think it's preferred to have godoc comments convey the API functionality/contract and function body comments to document the implementation details. Looks like your current PR aligns with that. But I'm not too picky either, since personally I tend to read the source code as the source of truth, regardless of any API doc :)

- govc: Add size (`s`) flag to `snapshot.tree` subcommand
- Add `object.SnapshotSize` and helper functions
  to support calculating snapshot size from other
  client code

Credit to @dougm for providing successive code examples,
explanation and guidance for understanding the required
steps to implement this support.

As noted on vmwareGH-2243, code provided by @dougm was (AFAIK)
based heavily on existing C# code for PowerCLI
implementation of the `Get-Snapshot` cmdlet.

- credit: @dougm
- refs vmware#2243
@atc0005 atc0005 changed the title WIP: Add govc snapshot size command Add govc snapshot size command, standalone SnapshotSize function Feb 17, 2021
@atc0005 atc0005 force-pushed the i2243-attempt-to-understand-snapshot-size-calc-logic branch from b04190d to d3d49a3 Compare February 17, 2021 11:15
@atc0005 atc0005 marked this pull request as ready for review February 17, 2021 11:15
@atc0005
Copy link
Contributor Author

atc0005 commented Feb 17, 2021

@dougm Squashed commits and rebased on current master branch content. Ready for review.

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.

Awesome, thanks @atc0005 !

@dougm dougm merged commit 755edac into vmware:master Feb 19, 2021
@atc0005
Copy link
Contributor Author

atc0005 commented Feb 19, 2021

Awesome, thanks @atc0005 !

Thank you for all of the help with this! I learned a lot along the way.

@atc0005 atc0005 deleted the i2243-attempt-to-understand-snapshot-size-calc-logic branch February 19, 2021 13:42
atc0005 added a commit to atc0005/govmomi that referenced this pull request Aug 23, 2023
Fix gosec G601 "Implicit memory aliasing in for loop" error
by reassigning the iteration variable inside the loop.

refs vmwareGH-2243
refs vmwareGH-2269
priyanka19-98 pushed a commit to priyanka19-98/govmomi that referenced this pull request Jan 17, 2024
Fix gosec G601 "Implicit memory aliasing in for loop" error
by reassigning the iteration variable inside the loop.

refs vmwareGH-2243
refs vmwareGH-2269
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.

How to get paired name/size values for each snapshot associated with a VM?
2 participants