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 snapshot size to snapshot.tree #1197

Closed
Matty9191 opened this issue Aug 9, 2018 · 5 comments
Closed

Add snapshot size to snapshot.tree #1197

Matty9191 opened this issue Aug 9, 2018 · 5 comments

Comments

@Matty9191
Copy link

It would be really cool to be able to retrieve the size of each VM snapshot by passing a size argument to snapshot.tree.

@dougm
Copy link
Member

dougm commented Aug 11, 2018

Taking a quick look where we can find this data, it would be useful if you could share the output of this command in your environment and let us know if the Size field alone looks correct:

% govc vm.info -json '*' | jq '.VirtualMachines[].LayoutEx.File[] | select(.Type == "snapshotData")'
{
  "Key": 6,
  "Name": "[datastore1] foo/foo-Snapshot1.vmsn",
  "Type": "snapshotData",
  "Size": 1120676,
  "UniqueSize": 1120676,
  "BackingObjectId": "",
  "Accessible": true
}

@atc0005
Copy link
Contributor

atc0005 commented Jan 16, 2021

@dougm Having this support would likely be useful for other clients of the govmomi package as well. Do you see adding it as a field to the types.VirtualMachineSnapshotTree type?

@dougm
Copy link
Member

dougm commented Jan 16, 2021

@atc0005 agreed it would be generally useful. We can't add fields to vim25/types however, those are generated from SDK spec (wsdl). But you can add helper types and methods by using a different type. A few examples:

type AuthorizationRoleList []types.AuthorizationRole
func (l AuthorizationRoleList) ById(id int32) *types.AuthorizationRole {
for _, role := range l {
if role.RoleId == id {
return &role
}
}
return nil
}
func (l AuthorizationRoleList) ByName(name string) *types.AuthorizationRole {
for _, role := range l {
if role.Name == name {
return &role
}
}
return nil
}

govmomi/license/manager.go

Lines 183 to 195 in c43a1c8

type InfoList []types.LicenseManagerLicenseInfo
func (l InfoList) WithFeature(key string) InfoList {
var result InfoList
for _, license := range l {
if HasFeature(license, key) {
result = append(result, license)
}
}
return result
}

// VirtualDeviceList provides helper methods for working with a list of virtual devices.
type VirtualDeviceList []types.BaseVirtualDevice

// HostFirewallRulesetList provides helpers for a slice of types.HostFirewallRuleset
type HostFirewallRulesetList []types.HostFirewallRuleset
// ByRule returns a HostFirewallRulesetList where Direction, PortType and Protocol are equal and Port is within range
func (l HostFirewallRulesetList) ByRule(rule types.HostFirewallRule) HostFirewallRulesetList {

There's more too, but those should give you the idea. I think similar could be done for types.VirtualMachineSnapshotTree

@atc0005
Copy link
Contributor

atc0005 commented Jan 16, 2021

@dougm: Taking a quick look where we can find this data, it would be useful if you could share the output of this command in your environment and let us know if the Size field alone looks correct:

FWIW: This isn't from govc, but accessing the Size field seems to yield the size of the vmsn file itself (e.g., RHEL7-TEST-Snapshot9.vmsn) and not the snapshot as "seen" by Get-Snapshot PowerCLI cmdlet or the vSphere web client. Your question was from a bit ago, but since I'm working on this I thought I'd offer the feedback, just in case it was useful.

@dougm dougm added this to the 0.25 milestone Feb 19, 2021
@dougm
Copy link
Member

dougm commented Feb 19, 2021

#2269 added a -s flag to the snapshot.tree command.

@dougm dougm closed this as completed Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants