private AsyncAction GetCleanActionForPoolPatch(Pool_patch patch) { if (patch == null || patch.Connection == null || !patch.Connection.IsConnected) { return(null); } if (patch.HostsAppliedTo().Count == 0) { return(new RemovePatchAction(patch)); } return(new DelegatedAsyncAction(patch.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_patch.async_pool_clean(session, patch.opaque_ref))); }
public void UpdateDetails() { _imageCell.Value = expanded ? Resources.expanded_triangle : Resources.contracted_triangle; if (_isFile) { _nameCell.Value = System.IO.Path.GetFileName(_patchPath); FileInfo fileInfo = new FileInfo(_patchPath); string description = expanded ? fileInfo.Exists ? String.Format(Messages.PATCH_EXPANDED_DESCRIPTION , _patchPath, fileInfo.CreationTime, fileInfo.LastWriteTime, Util.DiskSizeString(fileInfo.Length)) : String.Format(Messages.PATCH_NOT_FOUND_EXPANDED_DESCRIPTION, _patchPath) : _patchPath; UpdateFileDetails(description, fileInfo.Exists ? Messages.NOT_UPLOADED : Messages.PATCH_NOT_FOUND); } else { //It works across connections _nameCell.Value = Helpers.GetName(Patch); StringBuilder appliedOn = new StringBuilder(Messages.APPLIED_ON); List <Host> hostsAppliedTo = new List <Host>(); foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy) { Pool_patch poolPatch = xenConnection.Cache.Find_By_Uuid <Pool_patch>(Patch.uuid); if (poolPatch != null) { hostsAppliedTo.AddRange(poolPatch.HostsAppliedTo()); } } if (hostsAppliedTo.Count > 0) { appliedOn.Append(Helpers.GetListOfNames(hostsAppliedTo)); } else { appliedOn.Append(Messages.NONE); } _descriptionCell.Value = expanded ? String.Format("{0}\n{1}", _patch.Description, appliedOn.ToString()) : _patch.Description; int totalNumberHostsRunning = 0; foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy) { foreach (Host host in xenConnection.Cache.Hosts) { totalNumberHostsRunning++; } } if (hostsAppliedTo.Count == 0) { _statusCell.Value = Messages.NOT_APPLIED; } else if (hostsAppliedTo.Count == totalNumberHostsRunning) { _statusCell.Value = Messages.FULLY_APPLIED; this.Enabled = false; } else { List <Host> appliedTo = Patch.HostsAppliedTo(); if (appliedTo.Count > 0 && appliedTo[0].isOEM) { _statusCell.Value = Messages.FULLY_APPLIED; this.Enabled = false; } else { _statusCell.Value = Messages.PARTIALLY_APPLIED; } } } }