public CopyPatchFromHostToOther(IXenConnection connection, Host hostDestiny, Pool_patch patchToCopy) : base(connection, Messages.UPLOADING_PATCH, true) { _hostDestiny = hostDestiny; _patchToCopy = patchToCopy; Host = _hostDestiny; }
public void AlreadyInstalledOneFromMinimalForCurrentVersion() { // Arrange var serverVersions = GetAVersionWithGivenNumberOfPatches(1); var patch = serverVersions.First().Patches[0]; Pool_patch pool_patch = new Pool_patch(); pool_patch.uuid = patch.Uuid; var master = GetAMockHost(serverVersions.First().Oem, serverVersions.First().BuildNumber, new List<Pool_patch>() { pool_patch }); SetXenServerVersionsInUpdates(serverVersions); // Act var upgradeSequence = XenAdmin.Core.Updates.GetUpgradeSequence(master.Object.Connection); // Assert Assert.NotNull(upgradeSequence); Assert.AreEqual(1, upgradeSequence.Count); Assert.NotNull(upgradeSequence.First().Key); Assert.AreEqual(upgradeSequence.First().Key.uuid, master.Object.uuid); Assert.NotNull(upgradeSequence.First().Value); Assert.AreEqual(upgradeSequence.First().Value.Count, 0); }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); canUpload = true; canDownload = true; UpdateButtons(); if (SelectedUpdateType == UpdateType.Existing) _patch = SelectedExistingPatch; if (direction == PageLoadedDirection.Forward) { flickerFreeListBox1.Items.Clear(); var selectedPatch = SelectedUpdateAlert != null ? ((XenServerPatchAlert)SelectedUpdateAlert).Patch : null; if (selectedPatch != null && String.IsNullOrEmpty(SelectedNewPatchPath) && (!AllDownloadedPatches.Any(kvp => kvp.Key == selectedPatch.Uuid) || String.IsNullOrEmpty(AllDownloadedPatches[selectedPatch.Uuid]) || !File.Exists(AllDownloadedPatches[selectedPatch.Uuid]))) { DownloadFile(); label2.Text = Messages.PATCHINGWIZARD_UPLOADPAGE_MESSAGE_DOWNLOAD_AND_UPLOAD; pageTitle = Messages.PATCHINGWIZARD_UPLOADPAGE_TITLE_DOWNLOAD_AND_UPLOAD; } else { label2.Text = Messages.PATCHINGWIZARD_UPLOADPAGE_MESSAGE_ONLY_UPLOAD; pageTitle = Messages.PATCHINGWIZARD_UPLOADPAGE_TITLE_ONLY_UPLOAD; if (selectedPatch != null && AllDownloadedPatches.ContainsKey(selectedPatch.Uuid)) SelectedNewPatchPath = AllDownloadedPatches[selectedPatch.Uuid]; PrepareUploadActions(); TryUploading(); } } }
public CleanupDiskSpaceAction(Host host, Pool_patch excludedPatch, bool suppressHistory) : base(host.Connection, Messages.ACTION_CLEANUP_DISK_SPACE_TITLE, "", suppressHistory) { if (host == null) throw new ArgumentNullException("host"); Host = host; this.excludedPatch = excludedPatch; }
public PoolPatchCleanAction(Pool pool, Pool_patch patch, bool suppressHistory) : base(pool.Connection, string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATE, patch.Name, pool.Name), suppressHistory) { this.patch = patch; if (patch == null) throw new ArgumentNullException("pool_patch"); #region RBAC Dependencies ApiMethodsToRoleCheck.Add("pool_patch_pool_clean"); #endregion }
private void singleAction_Completed(ActionBase sender) { var action = sender as AsyncAction; if (action == null) { return; } action.Changed -= singleAction_Changed; action.Completed -= singleAction_Completed; Program.Invoke(this, () => { if (action.Succeeded) { Host master = Helpers.GetMaster(action.Connection); if (action is UploadPatchAction) { _patch = (action as UploadPatchAction).PatchRefs[master]; } if (action is CopyPatchFromHostToOther && action.Host != null) { _patch = action.Host.Connection.Cache.Resolve((action as CopyPatchFromHostToOther).NewPatchRef); } if (_patch != null && !NewUploadedPatches.ContainsKey(_patch)) { NewUploadedPatches.Add(_patch, SelectedNewPatchPath); } if (action is UploadSupplementalPackAction) { foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefs) { SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value); } AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi))); } if (action is DownloadAndUnzipXenServerPatchAction) { SelectedNewPatchPath = ((DownloadAndUnzipXenServerPatchAction)action).PatchPath; if (SelectedUpdateAlert is XenServerPatchAlert && (SelectedUpdateAlert as XenServerPatchAlert).Patch != null) { AllDownloadedPatches.Add((SelectedUpdateAlert as XenServerPatchAlert).Patch.Uuid, SelectedNewPatchPath); } _patch = null; PrepareUploadActions(); TryUploading(); } } }); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { lock (_lock) { Program.Invoke(this, () => { dataGridView1.Rows.Clear(); progressBar1.Value = 0; }); Pool_patch patch = e.Argument as Pool_patch; List <KeyValuePair <string, List <Check> > > checks = GenerateChecks(patch); _numberChecks = checks.Count; for (int i = 0; i < checks.Count; i++) { if (_worker.CancellationPending) { e.Cancel = true; return; } List <Check> checkGroup = checks[i].Value; PreCheckHeaderRow headerRow = new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, checks[i].Key)); _worker.ReportProgress(5, headerRow); PreCheckResult precheckResult = PreCheckResult.OK; for (int j = 0; j < checkGroup.Count; j++) { if (_worker.CancellationPending) { e.Cancel = true; return; } Check check = checkGroup[j]; foreach (PreCheckHostRow row in ExecuteCheck(check)) { if (precheckResult != PreCheckResult.Failed && row.Problem != null) { precheckResult = row.IsProblem ? PreCheckResult.Failed : PreCheckResult.Warning; } _worker.ReportProgress(PercentageSelectedServers(j + 1), row); } } lock (_update_grid_lock) { headerRow.UpdateDescription(precheckResult); } } } }
protected override void RunWithSession(ref Session session) { try { var mapping = patchMappings.FirstOrDefault(pm => pm.MasterHost != null && master != null && pm.MasterHost.uuid == master.uuid && pm.XenServerPatch.Equals(patch)); if (!Helpers.ElyOrGreater(session.Connection)) { Pool_patch poolPatch = null; if (mapping != null && mapping.Pool_patch != null && mapping.Pool_patch.opaque_ref != null) { poolPatch = mapping.Pool_patch; } else { poolPatch = session.Connection.Cache.Pool_patches.FirstOrDefault(pp => string.Equals(pp.uuid, patch.Uuid, StringComparison.InvariantCultureIgnoreCase)); } if (poolPatch != null && poolPatch.opaque_ref != null) { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolPatch.Name())); var task = Pool_patch.async_pool_clean(session, mapping.Pool_patch.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); patchMappings.Remove(mapping); } } else { if (mapping != null && mapping.Pool_update != null && mapping.Pool_update.opaque_ref != null) { var poolUpdate = mapping.Pool_update; AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolUpdate.Name())); Pool_update.pool_clean(session, poolUpdate.opaque_ref); if (!poolUpdate.AppliedOnHosts().Any()) { Pool_update.destroy(session, poolUpdate.opaque_ref); } patchMappings.Remove(mapping); } } } catch (Exception ex) { //best effort log.Error("Failed to remove update from the server.", ex); } }
protected override void Run() { this.Description = string.Format(Messages.REMOVING_UPDATE, patch.Name()); List <Pool_patch> poolPatches = new List <Pool_patch>(Connection.Cache.Pool_patches); var poolPatch = poolPatches.Find(p => string.Equals(p.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase)); if (poolPatch != null) { Pool_patch.pool_clean(Session, poolPatch.opaque_ref); } Description = String.Format(Messages.REMOVED_UPDATE, patch.Name()); }
protected virtual List <KeyValuePair <string, List <Check> > > GenerateChecks(Pool_patch patch) { List <Host> applicableServers = patch != null?SelectedServers.Where(h => patch.AppliedOn(h) == DateTime.MaxValue).ToList() : SelectedServers; List <KeyValuePair <string, List <Check> > > checks = GenerateCommonChecks(applicableServers); List <Check> checkGroup; //Checking other things if (patch != null) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_SERVER_SIDE_STATUS, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { List <Pool_patch> poolPatches = new List <Pool_patch>(host.Connection.Cache.Pool_patches); Pool_patch poolPatchFromHost = poolPatches.Find(otherPatch => string.Equals(otherPatch.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase)); checkGroup.Add(new PatchPrecheckCheck(host, poolPatchFromHost, LivePatchCodesByHost)); } } //Checking if the host needs a reboot if (!IsInAutomatedUpdatesMode) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_SERVER_NEEDS_REBOOT, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; var guidance = patch != null ? patch.after_apply_guidance : new List <after_apply_guidance> { after_apply_guidance.restartHost }; foreach (var host in applicableServers) { checkGroup.Add(new HostNeedsRebootCheck(host, guidance, LivePatchCodesByHost)); } } //Checking can evacuate host //CA-97061 - evacuate host -> suspended VMs. This is only needed for restartHost //Also include this check for the supplemental packs (patch == null), as their guidance is restartHost if (patch == null || patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_CANEVACUATE_STATUS, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in applicableServers) { checkGroup.Add(new AssertCanEvacuateCheck(host, LivePatchCodesByHost)); } } return(checks); }
public PoolPatchCleanAction(Pool pool, Pool_patch patch, bool suppressHistory) : base(pool.Connection, string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATE, patch.Name(), pool.Name()), suppressHistory) { this.patch = patch; if (patch == null) { throw new ArgumentNullException("pool_patch"); } #region RBAC Dependencies ApiMethodsToRoleCheck.Add("pool_patch.pool_clean"); #endregion }
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))); }
private void UploadAndApplyPatch(Host host, Session session) { var patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID); if (patch == null) { var master = Helpers.GetMaster(host.Connection); var filePath = Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update)); var action = new Actions.UploadPatchAction(master.Connection, filePath); action.RunExternal(session); patch = action.PatchRefs[master]; } Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref); }
protected override Problem RunCheck() { if (!Host.IsLive) { return(new HostNotLiveWarning(this, Host)); } if (!Host.Connection.IsConnected) { throw new EndOfStreamException(Helpers.GetName(Host.Connection)); } Session session = Host.Connection.DuplicateSession(); // // Check patch isn't already applied here // if (Patch.AppliedOn(Host) != DateTime.MaxValue) { return(new PatchAlreadyApplied(this, Host)); } try { return(FindProblem(Pool_patch.precheck(session, Patch.opaque_ref, Host.opaque_ref))); } catch (Failure f) { log.Error(f.ToString()); if (f.ErrorDescription.Count > 0) { log.Error(f.ErrorDescription[0]); } if (f.ErrorDescription.Count > 1) { log.Error(f.ErrorDescription[1]); } if (f.ErrorDescription.Count > 2) { log.Error(f.ErrorDescription[2]); } if (f.ErrorDescription.Count > 3) { log.Error(f.ErrorDescription[3]); } // try and find problem from the xapi failure Problem problem = FindProblem(f); return(problem ?? new PrecheckFailed(this, Host, f)); } }
private void CleanUploadedPatches(bool forceCleanSelectedPatch = false) { var list = new List <AsyncAction>(); foreach (var mapping in PatchingWizard_UploadPage.PatchMappings) { Pool_patch patch = null; if (mapping is PoolPatchMapping patchMapping) { patch = patchMapping.Pool_patch; } else if (mapping is OtherLegacyMapping legacyMapping) { patch = legacyMapping.Pool_patch; } if (patch != null) { // exclude the selected patch; either the user wants to keep it or it has already been cleared in the patching page if (PatchingWizard_UploadPage.Patch == null || !string.Equals(patch.uuid, PatchingWizard_UploadPage.Patch.uuid, StringComparison.OrdinalIgnoreCase) || forceCleanSelectedPatch) { list.Add(GetCleanActionForPoolPatch(patch)); } continue; } if (mapping is PoolUpdateMapping updateMapping) { list.Add(GetCleanActionForPoolUpdate(updateMapping.Pool_update)); continue; } if (mapping is SuppPackMapping suppPackMapping) { if (suppPackMapping.Pool_update != null) { list.Add(GetCleanActionForPoolUpdate(suppPackMapping.Pool_update)); } else { list.AddRange(GetRemoveVdiActions(suppPackMapping.SuppPackVdis.Values.ToList())); } } } RunMultipleActions(Messages.PATCHINGWIZARD_REMOVE_UPDATES, Messages.PATCHINGWIZARD_REMOVING_UPDATES, Messages.PATCHINGWIZARD_REMOVED_UPDATES, list); }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = (from HostUpdateMapping hum in mappings let xpm = hum as XenServerPatchMapping where xpm != null && xpm.Matches(master, xenServerPatch) select xpm).FirstOrDefault(); if (mapping == null || !mapping.IsValid) { if (xenServerPatch != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, master.uuid); } throw new Exception("Pool_patch or Pool_update not found."); } try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, xenServerPatch.Name, host.Name())); XenRef <Task> task = null; if (mapping is PoolPatchMapping patchMapping) { task = Pool_patch.async_apply(session, patchMapping.Pool_patch.opaque_ref, host.opaque_ref); } else if (mapping is PoolUpdateMapping updateMapping) { task = Pool_update.async_apply(session, updateMapping.Pool_update.opaque_ref, host.opaque_ref); } PollTaskForResultAndDestroy(Connection, ref session, task); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && (f.ErrorDescription[0] == Failure.PATCH_ALREADY_APPLIED || f.ErrorDescription[0] == Failure.UPDATE_ALREADY_APPLIED)) { log.InfoFormat("The update {0} is already applied on {1}. Ignoring this error.", xenServerPatch.Name, host.Name()); ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, xenServerPatch.Name, host.Name())); } else { throw; } } }
private static List <XenRef <VM> > RunningVMs(Host host, Pool_patch patch) { List <XenRef <VM> > vms = new List <XenRef <VM> >(); foreach (VM vm in patch.Connection.ResolveAll(host.resident_VMs)) { if (!vm.is_a_real_vm) { continue; } vms.Add(new XenRef <VM>(vm.opaque_ref)); } return(vms); }
protected override void Run() { Description = String.Format(Messages.REMOVING_UPDATE, patch.Name()); try { RelatedTask = Pool_patch.async_destroy(Session, patch.opaque_ref); PollToCompletion(); } catch (Failure f) { log.Error("Clean up failed", f); } Description = String.Format(Messages.REMOVED_UPDATE, patch.Name()); }
public PoolPatchMapping(XenServerPatch xenServerPatch, Pool_patch pool_patch, Host masterHost) { if (xenServerPatch == null) throw new ArgumentNullException("xenServerPatch"); if (pool_patch == null) throw new ArgumentNullException("pool_patch"); if (masterHost == null) throw new ArgumentNullException("masterHost"); this.XenServerPatch = xenServerPatch; this.Pool_patch = pool_patch; this.MasterHost = masterHost; }
protected override void RunWithSession(ref Session session) { var host = GetResolvedHost(); // evacuate the host, if needed, before applying the update if (_hostNeedsEvacuated) { EvacuateHost(ref session); } AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, _patch.Name(), host.Name())); XenRef <Task> task = Pool_patch.async_apply(session, _patch.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
protected override void Run() { SafeToExit = false; TotalSize = (embeddedHosts.Count > 0 ? embeddedHosts.Count * FileSize(embeddedPatchPath) : 0) + (retailHosts.Count > 0 ? retailHosts.Count * FileSize(retailPatchPath) : 0); foreach (Host host in embeddedHosts) { UploadEmbeddedPatch(host); } foreach (Host host in retailHosts) { try { patches[host] = UploadRetailPatch(host); } catch (Failure f) { // Need to check if the patch already exists. // If it does, and we're upload multiple patches // (ie from the wizard) then we don't care about // throwing the error if (f.ErrorDescription != null && f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_ALREADY_EXISTS && embeddedHosts.Count + retailHosts.Count > 1) { string uuid = f.ErrorDescription[1]; Session session = host.Connection.DuplicateSession(); patches[host] = Connection.Resolve(Pool_patch.get_by_uuid(session, uuid)); } else { throw; } } } if (embeddedHosts.Count + retailHosts.Count > 1) { this.Description = Messages.ALL_UPDATES_UPLOADED; } }
public string ModeRetailPatch(List<Host> servers, Pool_patch patch) { StringBuilder sbLog = new StringBuilder(); foreach (after_apply_guidance guide in patch.after_apply_guidance) { sbLog.AppendLine(GetGuideMessage(guide)); switch (guide) { case after_apply_guidance.restartHost: case after_apply_guidance.restartXAPI: foreach (Host host in servers) { if (host.IsMaster()) sbLog.AppendFormat("\t{0} ({1})\r\n", host.Name, Messages.MASTER); else sbLog.AppendFormat("\t{0}\r\n", host.Name); } break; case after_apply_guidance.restartPV: foreach (VM vm in Helpers.VMsRunningOn(servers)) { if (vm.IsHVM) continue; sbLog.AppendFormat("\t{0}\r\n", vm.Name); } break; case after_apply_guidance.restartHVM: foreach (VM vm in Helpers.VMsRunningOn(servers)) { if (!vm.IsHVM) continue; sbLog.AppendFormat("\t{0}\r\n", vm.Name); } break; } } if (patch.after_apply_guidance.Count == 0) sbLog.Append(Messages.PATCHINGWIZARD_MODEPAGE_NOACTION); return sbLog.ToString(); }
private List <PlanAction> CompileActionList(Host host, Pool_patch patch) { if (SelectedUpdateType == UpdateType.NewSuppPack) { return(CompileSuppPackActionList(host)); } List <PlanAction> actions = new List <PlanAction>(); if (patch == null) { return(actions); } List <XenRef <VM> > runningVMs = RunningVMs(host, patch); if (!host.isOEM) { actions.Add(new ApplyPatchPlanAction(host, patch)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)) { actions.Add(new EvacuateHostPlanAction(host)); actions.Add(new RebootHostPlanAction(host)); actions.Add(new BringBabiesBackAction(runningVMs, host, false)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI)) { actions.Add(new RestartAgentPlanAction(host)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHVM)) { actions.Add(new RebootVMsPlanAction(host, RunningHvmVMs(host))); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartPV)) { actions.Add(new RebootVMsPlanAction(host, RunningPvVMs(host))); } return(actions); }
private void singleAction_Completed(ActionBase sender) { var action = sender as AsyncAction; if (action == null) { return; } action.Changed -= singleAction_Changed; action.Completed -= singleAction_Completed; Program.Invoke(this, () => { if (action.Succeeded) { Host master = Helpers.GetMaster(action.Connection); if (action is UploadPatchAction) { _patch = (action as UploadPatchAction).PatchRefs[master]; } if (action is CopyPatchFromHostToOther && action.Host != null) { _patch = action.Host.Connection.Cache.Resolve((action as CopyPatchFromHostToOther).NewPatchRef); } if (_patch != null && !NewUploadedPatches.Contains(_patch)) { NewUploadedPatches.Add(_patch); } if (action is UploadSupplementalPackAction) { foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefs) { SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value); } AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi))); } } }); }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); canUpload = true; canDownload = true; UpdateButtons(); if (SelectedUpdateType == UpdateType.Existing) { _patch = SelectedExistingPatch; } if (direction == PageLoadedDirection.Forward) { PrepareUploadActions(); TryUploading(); } }
protected override void Run() { SafeToExit = false; if (patch.AppliedOn(host) != DateTime.MaxValue) { return; } XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name()); log.Debug(Description); var result = Pool_patch.apply(Session, patchRef, host.opaque_ref); log.DebugFormat(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name(), result); Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name()); }
private List <PlanAction> CompileActionList(Host host, Pool_patch patch) { if (SelectedUpdateType == UpdateType.ISO) { return(CompileSuppPackActionList(host)); } List <PlanAction> actions = new List <PlanAction>(); if (patch == null) { return(actions); } List <XenRef <VM> > runningVMs = RunningVMs(host, patch); actions.Add(new ApplyPatchPlanAction(host, patch)); if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost) && !(LivePatchCodesByHost != null && LivePatchCodesByHost.ContainsKey(host.uuid) && LivePatchCodesByHost[host.uuid] == livepatch_status.ok_livepatch_complete)) { actions.Add(new EvacuateHostPlanAction(host)); actions.Add(new RebootHostPlanAction(host)); actions.Add(new BringBabiesBackAction(runningVMs, host, false)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI)) { actions.Add(new RestartAgentPlanAction(host)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHVM)) { actions.Add(new RebootVMsPlanAction(host, RunningHvmVMs(host))); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartPV)) { actions.Add(new RebootVMsPlanAction(host, RunningPvVMs(host))); } return(actions); }
protected override void Run() { SafeToExit = false; if (patch.AppliedOn(host) != DateTime.MaxValue) { return; } XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name()); log.DebugFormat("Applying update '{0}' to server '{1}'", patch.Name(), host.Name()); RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref); PollToCompletion(); log.DebugFormat("Applied update '{0}' to server '{1}'. Result: {2}.", patch.Name(), host.Name(), Result); Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name()); }
protected override void RunWithSession(ref Session session) { var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch) && m.MasterHost != null && m.MasterHost.uuid == masterUuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, xenServerPatch.Name, host.Name())); var task = mapping.Pool_patch == null ? Pool_update.async_apply(session, mapping.Pool_update.opaque_ref, host.opaque_ref) : Pool_patch.async_apply(session, mapping.Pool_patch.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && (f.ErrorDescription[0] == Failure.PATCH_ALREADY_APPLIED || f.ErrorDescription[0] == Failure.UPDATE_ALREADY_APPLIED)) { log.InfoFormat("The update {0} is already applied on {1}. Ignoring this error.", xenServerPatch.Name, host.Name()); ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, xenServerPatch.Name, host.Name())); } else { throw; } } } else { if (xenServerPatch != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, masterUuid); } throw new Exception("Pool_patch or Pool_update not found."); } }
public PoolPatchMapping(XenServerPatch xenServerPatch, Pool_patch pool_patch, Host masterHost) { if (xenServerPatch == null) { throw new ArgumentNullException("xenServerPatch"); } if (pool_patch == null) { throw new ArgumentNullException("pool_patch"); } if (masterHost == null) { throw new ArgumentNullException("masterHost"); } this.XenServerPatch = xenServerPatch; this.Pool_patch = pool_patch; this.MasterHost = masterHost; }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); canUpload = true; canDownload = true; UpdateButtons(); if (SelectedUpdateType == UpdateType.Existing) { _patch = SelectedExistingPatch; } if (direction == PageLoadedDirection.Forward) { flickerFreeListBox1.Items.Clear(); var selectedPatch = SelectedUpdateAlert != null ? ((XenServerPatchAlert)SelectedUpdateAlert).Patch : null; if (selectedPatch != null && String.IsNullOrEmpty(SelectedNewPatchPath) && (!AllDownloadedPatches.Any(kvp => kvp.Key == selectedPatch.Uuid) || String.IsNullOrEmpty(AllDownloadedPatches[selectedPatch.Uuid]) || !File.Exists(AllDownloadedPatches[selectedPatch.Uuid]))) { DownloadFile(); label2.Text = Messages.PATCHINGWIZARD_UPLOADPAGE_MESSAGE_DOWNLOAD_AND_UPLOAD; pageTitle = Messages.PATCHINGWIZARD_UPLOADPAGE_TITLE_DOWNLOAD_AND_UPLOAD; } else { label2.Text = Messages.PATCHINGWIZARD_UPLOADPAGE_MESSAGE_ONLY_UPLOAD; pageTitle = Messages.PATCHINGWIZARD_UPLOADPAGE_TITLE_ONLY_UPLOAD; if (selectedPatch != null && AllDownloadedPatches.ContainsKey(selectedPatch.Uuid)) { SelectedNewPatchPath = AllDownloadedPatches[selectedPatch.Uuid]; } PrepareUploadActions(); TryUploading(); } } }
public sealed override void Apply(Host host, Session session) { Pool_patch patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID); if (patch == null) { var master = Helpers.GetMaster(host.Connection); var action = new Actions.UploadPatchAction(master.Connection, Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update))); action.RunExternal(session); patch = action.PatchRefs[master]; } Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref); int numberRetries = 0; do { Thread.Sleep(500); patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID); numberRetries++; } while (patch == null && numberRetries < 10); }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(host.Connection); var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid); if (mapping != null && mapping.Pool_patch != null) { var patchRef = mapping.Pool_patch; XenRef <Task> task = Pool_patch.async_apply(session, patchRef.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); } else { if (xenServerPatch != null && master != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, master.uuid); } throw new Exception("Pool_patch not found."); } }
private void ApplyPatch() { XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); try { this.Description = String.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name()); output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name()); output += Pool_patch.apply(Session, patchRef, host.opaque_ref); this.Description = String.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name()); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED) { output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE; output += f.ErrorDescription[1]; } throw; } }
/// <summary> /// This constructor is used to calculate the disk space requirements for installing or uploading a single patch /// </summary> public GetDiskSpaceRequirementsAction(Host host, Pool_patch patch, bool suppressHistory) : this(host, patch.Name, patch.size, suppressHistory) { currentPatch = patch; }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); try { if (SelectedUpdateType == UpdateType.Existing) _patch = SelectedExistingPatch; // catch selected servers, in order to restore selection after the dataGrid is reloaded List<Host> selectedServers = SelectedServers; dataGridViewHosts.Rows.Clear(); List<IXenConnection> xenConnections = ConnectionsManager.XenConnectionsCopy; xenConnections.Sort(); foreach (IXenConnection xenConnection in xenConnections) { Pool pool = Helpers.GetPool(xenConnection); bool hasPool = true; if (pool != null) { int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(pool)); Host master = pool.Connection.Resolve(pool.master); EnabledRow(master, SelectedUpdateType, index); } else { hasPool = false; } Host[] hosts = xenConnection.Cache.Hosts; Array.Sort(hosts); foreach (Host host in hosts) { int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(host, hasPool)); EnabledRow(host, SelectedUpdateType, index); } } // restore server selection SelectServers(selectedServers); } catch (Exception e) { log.Error(e, e); throw;//better throw an exception rather than closing the wizard suddenly and silently } }
public override void PageLeave(PageLoadedDirection direction, ref bool cancel) { try { if (direction == PageLoadedDirection.Forward) { if (!AllSelectedHostsConnected()) { foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows) row.UpdateIcon(); dataGridViewHosts.Invalidate(); cancel = true; return; } //Upload the patches to the masters if it is necessary List<Host> masters = SelectedMasters; //Do RBAC check foreach (Host master in masters) { if(Helpers.MidnightRideOrGreater(master.Connection)&&!(Role.CanPerform(new RbacMethodList("pool_patch.apply"),master.Connection))) { string nameLabel = master.Name; Pool pool = Helpers.GetPoolOfOne(master.Connection); if (pool != null) nameLabel = pool.Name; new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPDATES_WIZARD, master.Connection.Username, nameLabel), Messages.UPDATES_WIZARD)).ShowDialog(this); cancel = true; base.PageLeave(direction, ref cancel); return; } } switch (SelectedUpdateType) { case UpdateType.NewRetail: foreach (Host selectedServer in masters) { Host master = Helpers.GetMaster(selectedServer.Connection); UploadPatchAction action = new UploadPatchAction(master.Connection, SelectedNewPatch); new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(); if (action.Succeeded) { _patch = action.PatchRefs[master]; NewUploadedPatches.Add(_patch); } else { cancel = true; break; } } break; case UpdateType.Existing: foreach (Host selectedServer in masters) { List<Pool_patch> poolPatches = new List<Pool_patch>(selectedServer.Connection.Cache.Pool_patches); if (poolPatches.Find(patch => patch.uuid == SelectedExistingPatch.uuid) == null) { //Download patch from server Upload in the selected server var actionCopyPatch = new CopyPatchFromHostToOther(SelectedExistingPatch.Connection, selectedServer, SelectedExistingPatch); new ActionProgressDialog(actionCopyPatch, ProgressBarStyle.Blocks).ShowDialog(); if (!actionCopyPatch.Succeeded) { cancel = true; break; } } } break; } } base.PageLeave(direction, ref cancel); } catch (Exception e) { log.Debug(e); throw;//better throw an exception rather than closing the wizard suddenly and silently } }
public HostOutOfSpaceProblem(Check check, Host host, Pool_patch patch, DiskSpaceRequirements diskSpaceReq) : base(check, host) { this.patch = patch; this.diskSpaceReq = diskSpaceReq; }
public IEnumerable<KeyValuePair<string, List<Check>>> GetGenerateChecks(Pool_patch patch) { return GenerateChecks(patch); }
protected override List<KeyValuePair<string, List<Check>>> GenerateChecks(Pool_patch patch) { List<KeyValuePair<string, List<Check>>> checks = new List<KeyValuePair<string, List<Check>>>(); //HostMaintenanceModeCheck checks checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_HOST_LIVENESS_STATUS, new List<Check>())); List<Check> checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new HostMaintenanceModeCheck(host)); } //HA checks checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_HA_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Pool pool in SelectedPools) { Host host = pool.Connection.Resolve(pool.master); if(host == null) continue; //WLB warning if (!Helpers.ClearwaterOrGreater(host.Connection)) checkGroup.Add(new HostHasWlbCheck(host)); checkGroup.Add(new HAOffCheck(host)); } //Checking can evacuate host checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_CANEVACUATE_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new AssertCanEvacuateUpgradeCheck(host)); } //PBDsPluggedCheck checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new PBDsPluggedCheck(host)); } //HotfixesCheck required for MNR, Cowley, Boston and Sanibel bool titleAdded = false; foreach (var host in SelectedServers) { if (new HotfixFactory().IsHotfixRequired(host) && !ManualUpgrade) { if (!titleAdded) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_UPGRADE_HOTFIX_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; titleAdded = true; } checkGroup.Add(new HostHasHotfixCheck(host)); } } //Upgrading to Clearwater and above - license changes warning and deprecations if(SelectedServers.Any(h=> !Helpers.ClearwaterOrGreater(h))) { //License changes if (SelectedServers.Any(h => Host.GetEdition(h.edition) != Host.Edition.EnterpriseXD && Host.GetEdition(h.edition) != Host.Edition.XenDesktop)) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_LICENSING_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new UpgradingFromTampaAndOlderCheck(host)); } } //WSS removal checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_WSS_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new HostHasWssCheck(host)); } //VMP[RP]removal checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_VMPR_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new VmprActivatedCheck(host)); } } return checks; }
protected virtual List<KeyValuePair<string, List<Check>>> GenerateChecks(Pool_patch patch) { List<KeyValuePair<string, List<Check>>> checks = new List<KeyValuePair<string, List<Check>>>(); //HostLivenessCheck checks checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_HOST_LIVENESS_STATUS, new List<Check>())); List<Check> checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new HostLivenessCheck(host)); } //HA checks checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_HA_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { if (Helpers.HostIsMaster(host)) checkGroup.Add(new HAOffCheck(host)); } //Checking can evacuate host //CA-97061 - evacuate host -> suspended VMs. This is only needed for restartHost //Also include this check for the supplemental packs (patch == null), as their guidance is restartHost if (patch == null || patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_CANEVACUATE_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new AssertCanEvacuateCheck(host)); } } //PBDsPluggedCheck checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new PBDsPluggedCheck(host)); } //Checking other things if (patch != null) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_SERVER_SIDE_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { List<Pool_patch> poolPatches = new List<Pool_patch>(host.Connection.Cache.Pool_patches); Pool_patch poolPatchFromHost = poolPatches.Find(otherPatch => string.Equals(otherPatch.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase)); checkGroup.Add(new PatchPrecheckCheck(host, poolPatchFromHost)); } } return checks; }
private List<PlanAction> CompileActionList(Host host, Pool_patch patch) { if (SelectedUpdateType == UpdateType.NewSuppPack) return CompileSuppPackActionList(host); List<PlanAction> actions = new List<PlanAction>(); if (patch == null) return actions; List<XenRef<VM>> runningVMs = RunningVMs(host, patch); if (!host.isOEM) actions.Add(new ApplyPatchPlanAction(host, patch)); if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)) { actions.Add(new EvacuateHostPlanAction(host)); actions.Add(new RebootHostPlanAction(host)); actions.Add(new BringBabiesBackAction(runningVMs, host, false)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI)) { actions.Add(new RestartAgentPlanAction(host)); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHVM)) { actions.Add(new RebootVMsPlanAction(host, RunningHvmVMs(host))); } if (patch.after_apply_guidance.Contains(after_apply_guidance.restartPV)) { actions.Add(new RebootVMsPlanAction(host, RunningPvVMs(host))); } return actions; }
private void ApplyPatch(Host host, Pool_patch patch) { // Set the correct connection object, for RecomputeCanCancel Connection = host.Connection; Session session = host.Connection.DuplicateSession(); XenRef<Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); try { this.Description = String.Format(Messages.APPLYING_PATCH, patch.Name, host.Name); output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name, host.Name); output += Pool_patch.apply(session, patchRef, host.opaque_ref); this.Description = String.Format(Messages.PATCH_APPLIED, patch.Name, host.Name); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED) { output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE; output += f.ErrorDescription[1]; } throw; } finally { Connection = null; } }
protected XenRef<Pool_patch> BringPatchToPoolForHost(Host host, Pool_patch patch) { // Check the patch exists on the pool this host is connected to XenRef<Pool_patch> patch_ref = host.Connection.Cache.FindRef(patch); if (patch_ref != null) return patch_ref; Description = String.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name); // 1st download patch from the pool that has it (the connection on the xenobject) string filename = Path.GetTempFileName(); try { Connection = patch.Connection; Session = patch.Connection.DuplicateSession(); try { HTTPHelper.Get(this, true, filename, patch.Connection.Hostname, (HTTP_actions.get_sss)HTTP_actions.get_pool_patch_download, Session.uuid, patch.uuid); } catch (Exception e) { throw new PatchDownloadFailedException(string.Format(Messages.PATCH_DOWNLOAD_FAILED, patch.name_label, patch.Connection.Name), e); } finally { Connection = null; Session = null; } // Then, put it on the pool that doesn't have it Description = String.Format(Messages.UPLOADING_PATCH_TO, host.Name); Connection = host.Connection; Session = host.Connection.DuplicateSession(); try { string result = HTTPHelper.Put(this, true, filename, host.Connection.Hostname, (HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, Session.uuid); return new XenRef<Pool_patch>(result); } finally { Connection = null; Session = null; Description = String.Format(Messages.PATCH_UPLOADED, host.Name); } } finally { File.Delete(filename); } }
protected virtual List<KeyValuePair<string, List<Check>>> GenerateChecks(Pool_patch patch) { List<KeyValuePair<string, List<Check>>> checks = GenerateCommonChecks(); List<Check> checkGroup; //Checking other things if (patch != null) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_SERVER_SIDE_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { List<Pool_patch> poolPatches = new List<Pool_patch>(host.Connection.Cache.Pool_patches); Pool_patch poolPatchFromHost = poolPatches.Find(otherPatch => string.Equals(otherPatch.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase)); checkGroup.Add(new PatchPrecheckCheck(host, poolPatchFromHost, LivePatchCodesByHost)); } } //Checking if the host needs a reboot if (!IsInAutomatedUpdatesMode) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_SERVER_NEEDS_REBOOT, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; var guidance = patch != null ? patch.after_apply_guidance : new List<after_apply_guidance> {after_apply_guidance.restartHost}; foreach (var host in SelectedServers) { checkGroup.Add(new HostNeedsRebootCheck(host, guidance, LivePatchCodesByHost)); } } //Checking can evacuate host //CA-97061 - evacuate host -> suspended VMs. This is only needed for restartHost //Also include this check for the supplemental packs (patch == null), as their guidance is restartHost if (patch == null || patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)) { checks.Add(new KeyValuePair<string, List<Check>>(Messages.CHECKING_CANEVACUATE_STATUS, new List<Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new AssertCanEvacuateCheck(host, LivePatchCodesByHost)); } } return checks; }
public PatchPrecheckCheck(Host host, Pool_patch patch, Dictionary<string, livepatch_status> livePatchCodesByHost) : base(host) { _patch = patch; this.livePatchCodesByHost = livePatchCodesByHost; }
private static List<XenRef<VM>> RunningVMs(Host host, Pool_patch patch) { List<XenRef<VM>> vms = new List<XenRef<VM>>(); foreach (VM vm in patch.Connection.ResolveAll(host.resident_VMs)) { if (!vm.is_a_real_vm) continue; vms.Add(new XenRef<VM>(vm.opaque_ref)); } return vms; }
private static bool PatchExistsOnPool(Pool_patch patch, Host poolMaster) { var poolPatches = new List<Pool_patch>(poolMaster.Connection.Cache.Pool_patches); return (poolPatches.Exists(p => string.Equals(p.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase))); }
private void PrepareUploadActions() { OnPageUpdated(); SuppPackVdis.Clear(); uploadActions.Clear(); //Upload the patches to the masters if it is necessary List<Host> masters = SelectedMasters; foreach (Host selectedServer in masters) { AsyncAction action = null; switch (SelectedUpdateType) { case UpdateType.NewRetail: if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer)) { bool deleteFileOnCancel = AllDownloadedPatches.ContainsValue(SelectedNewPatchPath); action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatchPath, true, deleteFileOnCancel); } break; case UpdateType.Existing: if (!PatchExistsOnPool(_patch, selectedServer)) { //Download patch from server Upload in the selected server action = new CopyPatchFromHostToOther(SelectedExistingPatch.Connection, selectedServer, SelectedExistingPatch); } break; case UpdateType.ISO: if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer)) { _poolUpdate = null; _patch = null; action = new UploadSupplementalPackAction( selectedServer.Connection, SelectedServers.Where(s => s.Connection == selectedServer.Connection).ToList(), SelectedNewPatchPath, true); } break; } if (action != null) { action.Changed += singleAction_Changed; action.Completed += singleAction_Completed; } else { _patch = GetPatchFromPatchPath(); } uploadActions.Add(selectedServer, action); } foreach (KeyValuePair<Host, AsyncAction> uploadAction in uploadActions) { flickerFreeListBox1.Items.Add(uploadAction); } flickerFreeListBox1.Refresh(); OnPageUpdated(); }
private void singleAction_Completed(ActionBase sender) { var action = sender as AsyncAction; if (action == null) return; action.Changed -= singleAction_Changed; action.Completed -= singleAction_Completed; Program.Invoke(this, () => { if (action.Succeeded) { Host master = Helpers.GetMaster(action.Connection); if (action is UploadPatchAction) { _patch = (action as UploadPatchAction).PatchRefs[master]; _poolUpdate = null; AddToUploadedUpdates(SelectedNewPatchPath, master); } if (action is CopyPatchFromHostToOther && action.Host != null) { _poolUpdate = null; _patch = action.Host.Connection.Cache.Resolve((action as CopyPatchFromHostToOther).NewPatchRef); } if (_patch != null && !NewUploadedPatches.ContainsKey(_patch)) { NewUploadedPatches.Add(_patch, SelectedNewPatchPath); _poolUpdate = null; } if (action is UploadSupplementalPackAction) { _patch = null; foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefsToCleanUp) { SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value); } AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi))); AddToUploadedUpdates(SelectedNewPatchPath, master); if (Helpers.ElyOrGreater(action.Connection)) { var newPoolUpdate = ((UploadSupplementalPackAction)action).PoolUpdate; if (newPoolUpdate != null) { _poolUpdate = newPoolUpdate; AllIntroducedPoolUpdates.Add(PoolUpdate); } } } if (action is DownloadAndUnzipXenServerPatchAction) { SelectedNewPatchPath = ((DownloadAndUnzipXenServerPatchAction)action).PatchPath; if (SelectedUpdateAlert is XenServerPatchAlert && (SelectedUpdateAlert as XenServerPatchAlert).Patch != null) { AllDownloadedPatches.Add((SelectedUpdateAlert as XenServerPatchAlert).Patch.Uuid, SelectedNewPatchPath); } _patch = null; PrepareUploadActions(); TryUploading(); } } else // if !action.Succeeded { if (action is UploadSupplementalPackAction) { _patch = null; _poolUpdate = null; foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefsToCleanUp) { SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value); } AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi))); } } }); }
private static bool PatchExistsOnPool(Pool_patch patch, Host poolMaster) { var poolPatches = new List<Pool_patch>(poolMaster.Connection.Cache.Pool_patches); return (poolPatches.Exists(p => p.uuid == patch.uuid)); }
/// <summary> /// This constructor is used to check disk space for uploading a single patch /// </summary> public CheckDiskSpaceForPatchUploadAction(Host host, Pool_patch patch, bool suppressHistory) : this(host, patch.Name, patch.size, suppressHistory) { }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); canUpload = true; canDownload = true; UpdateButtons(); if (SelectedUpdateType == UpdateType.Existing) _patch = SelectedExistingPatch; if (direction == PageLoadedDirection.Forward) { flickerFreeListBox1.Items.Clear(); var selectedPatch = SelectedUpdateAlert != null ? ((XenServerPatchAlert)SelectedUpdateAlert).Patch : null; if (selectedPatch != null && String.IsNullOrEmpty(SelectedNewPatch) && (!AllDownloadedPatches.Any(kvp => kvp.Key == selectedPatch.Uuid) || String.IsNullOrEmpty(AllDownloadedPatches[selectedPatch.Uuid]) || !File.Exists(AllDownloadedPatches[selectedPatch.Uuid]))) { DownloadFile(); } else { if (selectedPatch != null && AllDownloadedPatches.ContainsKey(selectedPatch.Uuid)) SelectedNewPatch = AllDownloadedPatches[selectedPatch.Uuid]; PrepareUploadActions(); TryUploading(); } } }
public RemoveUpdateFile(Pool pool, Pool_patch patch) : base(pool.Connection, string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATE, patch.Name, pool.Name)) { this._patchRef = new XenRef<Pool_patch>(patch); }
/// <summary> /// This constructor is used to remove a single 'normal' patch /// </summary> /// <param name="connection"></param> /// <param name="path"></param> public RemovePatchAction(Pool_patch patch) : base(patch.Connection, Messages.REMOVE_PATCH) { this.patch = patch; }
protected override Problem RunCheck() { if (!Host.IsLive) { return(new HostNotLiveWarning(this, Host)); } if (!Host.Connection.IsConnected) { throw new EndOfStreamException(Helpers.GetName(Host.Connection)); } Session session = Host.Connection.DuplicateSession(); // // Check patch isn't already applied here // if ((Patch != null && Patch.AppliedOn(Host) != DateTime.MaxValue) || (Update != null && Update.AppliedOn(Host))) { return(new PatchAlreadyApplied(this, Host)); } try { if (Patch != null) { string result = Pool_patch.precheck(session, Patch.opaque_ref, Host.opaque_ref); log.DebugFormat("Pool_patch.precheck returned: '{0}'", result); return(FindProblem(result)); } else if (Helpers.ElyOrGreater(Host)) { var livepatchStatus = Pool_update.precheck(session, Update.opaque_ref, Host.opaque_ref); log.DebugFormat("Pool_update.precheck returned livepatch_status: '{0}'", livepatchStatus); if (livePatchCodesByHost != null) { livePatchCodesByHost[Host.uuid] = livepatchStatus; } } return(null); } catch (Failure f) { log.Error(f.ToString()); if (f.ErrorDescription.Count > 0) { log.Error(f.ErrorDescription[0]); } if (f.ErrorDescription.Count > 1) { log.Error(f.ErrorDescription[1]); } if (f.ErrorDescription.Count > 2) { log.Error(f.ErrorDescription[2]); } if (f.ErrorDescription.Count > 3) { log.Error(f.ErrorDescription[3]); } // try and find problem from the xapi failure Problem problem = FindProblem(f); return(problem ?? new PrecheckFailed(this, Host, f)); } }
public PatchPrecheckCheck(Host host, Pool_patch patch, Dictionary <string, livepatch_status> livePatchCodesByHost) : base(host) { _patch = patch; this.livePatchCodesByHost = livePatchCodesByHost; }
public PatchPrecheckCheck(Host host, Pool_patch patch) : base(host) { _patch = patch; }
public PatchPrecheckCheck(Host host, Pool_patch patch) : this(host, patch, null) { }