Implement targeted VM property refresh and backfill logic for snapshot rows
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-13 16:09:29 +11:00
parent e2779f80c0
commit c446638eac
3 changed files with 286 additions and 0 deletions

View File

@@ -296,6 +296,24 @@ func (v *Vcenter) GetAllVMsWithProps() ([]mo.VirtualMachine, error) {
return vms, nil
}
// GetVMWithSnapshotPropsByRef retrieves snapshot-critical properties for a single VM reference.
// Used as a targeted fallback when bulk retrieval returns partial data for a VM.
func (v *Vcenter) GetVMWithSnapshotPropsByRef(ref types.ManagedObjectReference) (*mo.VirtualMachine, error) {
var vm mo.VirtualMachine
props := []string{
"name",
"parent",
"config",
"runtime.powerState",
"runtime.host",
"resourcePool",
}
if err := v.client.RetrieveOne(v.ctx, ref, props, &vm); err != nil {
return nil, err
}
return &vm, nil
}
// FindVmDeletionEvents returns a map of MoRef (VmId) to the deletion event time within the given window.
func (v *Vcenter) FindVmDeletionEvents(ctx context.Context, begin, end time.Time) (map[string]time.Time, error) {
return v.findVmDeletionEvents(ctx, begin, end, nil)