public string DeleteSnapshot(P2PBackup.Common.Node vm, string snapMoref) { string deleteTask = null; ObjectContent[] oCary = GetObjectProperties("VirtualMachine", new string[] { "snapshot" }, null /*GetVmMoRef(vm)*/); ObjectContent oc = null; ManagedObjectReference mor = null; ManagedObjectReference snapMor = null; DynamicProperty[] pcary = null; DynamicProperty pc = null; for (int oci = 0; oci < oCary.Length; oci++) { oc = oCary[oci]; mor = oc.obj; pcary = oc.propSet; if (mor.type != "VirtualMachine" || pcary == null) { continue; } for (int i = 0; i < pcary.Length; i++) { pc = pcary[i]; if (pc.val is VirtualMachineSnapshotInfo) { VirtualMachineSnapshotInfo snapInfo = (VirtualMachineSnapshotInfo)pc.val; ManagedObjectReference theSnapMor = snapInfo.currentSnapshot; if (theSnapMor.Value == snapMoref) { snapMor = theSnapMor; break; } } } if (snapMor != null) { break; } } if (snapMor != null) { if (LogEvent != null) { LogEvent(this, new LogEventArgs(0, Severity.INFO, "Deleting snapshot '" + snapMor.Value + "' for virtual node " + vm.ToString())); } try{ deleteTask = service.RemoveSnapshot_Task(snapMor, true).Value; } catch {} // timed-out getting vsphere response, ignore. } return(deleteTask); }