protected override List <KeyValuePair <string, List <Check> > > GenerateChecks(Pool_patch patch) { List <KeyValuePair <string, List <Check> > > checks = new List <KeyValuePair <string, List <Check> > >(); List <Check> checkGroup; //XenCenter version check (if any of the selected server version is not the latest) var latestCrVersion = Updates.XenServerVersions.FindAll(item => item.LatestCr).OrderByDescending(v => v.Version).FirstOrDefault(); if (latestCrVersion != null && SelectedServers.Any(host => new Version(Helpers.HostProductVersion(host)) < latestCrVersion.Version)) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_XENCENTER_VERSION, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; checkGroup.Add(new XenCenterVersionCheck(null)); } //HostMaintenanceModeCheck checks checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_HOST_LIVENESS_STATUS, new 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; } 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)); } } //iSL (StorageLink) check - CA-223486: only for pre-Creedence var preCreedenceServers = SelectedServers.Where(h => !Helpers.CreedenceOrGreater(h)).ToList(); if (preCreedenceServers.Any()) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_STORAGELINK_STATUS, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in preCreedenceServers) { checkGroup.Add(new HostHasUnsupportedStorageLinkSRCheck(host)); } } //SafeToUpgradeCheck - in automatic mode only if (!ManualUpgrade) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_SAFE_TO_UPGRADE, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new SafeToUpgradeCheck(host)); } } return(checks); }
private List <HostPlan> CompileAutomaticHostPlan(Pool pool, out List <Host> applicableHosts) { var poolHosts = pool.Connection.Cache.Hosts.ToList(); SelectedServers.Sort(); //master first and then the slaves var hostplans = new List <HostPlan>(); if (SelectedUpdateType == UpdateType.ISO) { var poolUpdates = new List <Pool_update>(pool.Connection.Cache.Pool_updates); var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, PoolUpdate.uuid, StringComparison.OrdinalIgnoreCase)); if (poolUpdate != null) //ely or greater { foreach (var server in SelectedServers) { if (poolHosts.Contains(server) && !poolUpdate.AppliedOn(server)) { hostplans.Add(new HostPlan(server, null, CompilePoolUpdateActionList(server, poolUpdate), null)); } } } else if (SuppPackVdis != null) // supp pack { foreach (var server in SelectedServers) { if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server)) { var updateActions = new List <PlanAction> { new InstallSupplementalPackPlanAction(server, SuppPackVdis[server]), new RestartHostPlanAction(server, server.GetRunningVMs()) }; hostplans.Add(new HostPlan(server, null, updateActions, null)); } } } } else //legacy { var poolPatches = new List <Pool_patch>(pool.Connection.Cache.Pool_patches); var poolPatch = poolPatches.Find(p => Patch != null && string.Equals(p.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase)); if (poolPatch != null) { foreach (Host server in SelectedServers) { if (poolHosts.Contains(server) && poolPatch.AppliedOn(server) == DateTime.MaxValue) { hostplans.Add(new HostPlan(server, null, CompilePatchActionList(server, poolPatch), null)); } } } if (RemoveUpdateFile && hostplans.Count > 0) { hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, poolPatch)); } } applicableHosts = hostplans.Select(h => h.Host).ToList(); return(hostplans); }
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 { _poolUpdate = GetUpdateFromUpdatePath(); _patch = GetPatchFromPatchPath(); } uploadActions.Add(selectedServer, action); } foreach (KeyValuePair <Host, AsyncAction> uploadAction in uploadActions) { flickerFreeListBox1.Items.Add(uploadAction); } flickerFreeListBox1.Refresh(); OnPageUpdated(); }
private List <HostPlan> CompileManualHostPlan(Pool pool, out List <Host> applicableHosts) { var poolHosts = pool.Connection.Cache.Hosts.ToList(); SelectedServers.Sort(); //master first and then the slaves var hostplans = new List <HostPlan>(); if (SelectedUpdateType == UpdateType.ISO) { if (PoolUpdate != null) //ely or greater { foreach (var server in SelectedServers) { if (poolHosts.Contains(server)) { var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(server, PoolUpdate, LivePatchCodesByHost); var updateActions = new List <PlanAction> { new ApplyPoolUpdatePlanAction(server, PoolUpdate, hostRebootRequired) }; hostplans.Add(new HostPlan(server, null, updateActions, null)); } } } else if (SuppPackVdis != null) //supp pack { foreach (var server in SelectedServers) { if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server)) { var updateActions = new List <PlanAction> { new InstallSupplementalPackPlanAction(server, SuppPackVdis[server]) }; hostplans.Add(new HostPlan(server, null, updateActions, null)); } } } } else // legacy { foreach (var server in SelectedServers) { if (poolHosts.Contains(server)) { var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(server, Patch, LivePatchCodesByHost); var updateActions = new List <PlanAction> { new ApplyPatchPlanAction(server, Patch, hostRebootRequired) }; hostplans.Add(new HostPlan(server, null, updateActions, null)); } } if (RemoveUpdateFile && hostplans.Count > 0) { hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, Patch)); } } applicableHosts = hostplans.Select(h => h.Host).ToList(); return(hostplans); }
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; } 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)); } } //iSL (StorageLink) check - CA-223486: only for pre-Creedence var preCreedenceServers = SelectedServers.Where(h => !Helpers.CreedenceOrGreater(h)).ToList(); if (preCreedenceServers.Any()) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_STORAGELINK_STATUS, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in preCreedenceServers) { checkGroup.Add(new HostHasUnsupportedStorageLinkSRCheck(host)); } } //SafeToUpgradeCheck - in automatic mode only if (!ManualUpgrade) { checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_SAFE_TO_UPGRADE, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new SafeToUpgradeCheck(host)); } } return(checks); }
protected override void PageLoadedCore(PageLoadedDirection direction) { if (_thisPageHasBeenCompleted) { actionsWorker = null; return; } if (!IsAutomaticMode) { textBoxLog.Text = ManualTextInstructions; List <AsyncAction> actions = new List <AsyncAction>(); if (SelectedUpdateType == UpdateType.ISO && PoolUpdate != null) { //Ely or greater: iso update format foreach (var server in SelectedServers) { actions.Add(new ApplyUpdateAction(PoolUpdate, server)); } } else { //legacy mode if (SelectedUpdateType != UpdateType.ISO) { foreach (var server in SelectedServers) { actions.Add(new ApplyPatchAction(Patch, server)); } } else { actions.Add(new InstallSupplementalPackAction(SuppPackVdis, false)); } } if (RemoveUpdateFile && SelectedUpdateType != UpdateType.ISO) { foreach (Pool pool in SelectedPools) { actions.Add(new PoolPatchCleanAction(pool, Patch, false)); } } using (var multipleAction = new MultipleAction(Connection, "", "", "", actions, true, true, true)) { multipleAction.Changed += action_Changed; multipleAction.Completed += action_Completed; multipleAction.RunAsync(); } return; } _nextEnabled = false; OnPageUpdated(); List <PlanAction> planActions = new List <PlanAction>(); foreach (Pool pool in SelectedPools) { var poolHosts = new List <Host>(pool.Connection.Cache.Hosts); Host master = SelectedServers.Find(host => host.IsMaster() && poolHosts.Contains(host)); //For Ely or greater: ISO updates only if (SelectedUpdateType == UpdateType.ISO && Helpers.ElyOrGreater(pool.Connection)) //updates for Ely (or higher) are always ISO { var poolUpdates = new List <Pool_update>(pool.Connection.Cache.Pool_updates); var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, PoolUpdate.uuid, StringComparison.OrdinalIgnoreCase)); //master first if (master != null && !poolUpdate.AppliedOn(master)) { planActions.AddRange(CompilePoolUpdateActionList(master, poolUpdate)); } //other hosts foreach (var host in SelectedServers.Where(s => poolHosts.Contains(s) && !s.IsMaster() && !poolUpdate.AppliedOn(s)).ToList()) { planActions.AddRange(CompilePoolUpdateActionList(host, poolUpdate)); } } // Legacy (pre-Ely) case: either ISO for supplemental packs (Pool_patch == null) or patch (Pool_patch != null) else { Pool_patch poolPatch = null; if (SelectedUpdateType != UpdateType.ISO) { List <Pool_patch> poolPatches = new List <Pool_patch>(pool.Connection.Cache.Pool_patches); poolPatch = poolPatches.Find(delegate(Pool_patch otherPatch) { if (Patch != null) { return(string.Equals(otherPatch.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase)); } return(false); }); } //master first if (master != null && (poolPatch == null || poolPatch.AppliedOn(master) == DateTime.MaxValue)) { planActions.AddRange(CompileActionList(master, poolPatch)); } foreach (Host server in SelectedServers) { if (poolHosts.Contains(server)) { if (!server.IsMaster()) { // check patch isn't already applied here if (poolPatch == null || poolPatch.AppliedOn(server) == DateTime.MaxValue) { planActions.AddRange(CompileActionList(server, poolPatch)); } } } } if (RemoveUpdateFile) { planActions.Add(new RemoveUpdateFile(pool, poolPatch)); } } } //end pool in foreach planActions.Add(new UnwindProblemsAction(PrecheckProblemsActuallyResolved)); actionsWorker = new BackgroundWorker(); actionsWorker.DoWork += PatchingWizardAutomaticPatchWork; actionsWorker.WorkerReportsProgress = true; actionsWorker.ProgressChanged += actionsWorker_ProgressChanged; actionsWorker.RunWorkerCompleted += actionsWorker_RunWorkerCompleted; actionsWorker.WorkerSupportsCancellation = true; actionsWorker.RunWorkerAsync(planActions); }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); if (_thisPageHasBeenCompleted) { actionManualMode = null; actionsWorker = null; return; } if (!IsAutomaticMode) { if (SelectedUpdateType != UpdateType.NewSuppPack) { actionManualMode = new ApplyPatchAction(new List <Pool_patch> { Patch }, SelectedServers); } else { actionManualMode = new InstallSupplementalPackAction(SuppPackVdis, false); } actionManualMode.Changed += action_Changed; actionManualMode.Completed += action_Completed; textBoxLog.Text = ManualTextInstructions; actionManualMode.RunAsync(); return; } _nextEnabled = false; OnPageUpdated(); List <PlanAction> planActions = new List <PlanAction>(); foreach (Pool pool in SelectedPools) { Pool_patch poolPatch = null; if (SelectedUpdateType != UpdateType.NewSuppPack) { List <Pool_patch> poolPatches = new List <Pool_patch>(pool.Connection.Cache.Pool_patches); poolPatch = poolPatches.Find(delegate(Pool_patch otherPatch) { if (Patch != null) { return(string.Equals(otherPatch.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase)); } return(false); }); } List <Host> poolHosts = new List <Host>(pool.Connection.Cache.Hosts); Host master = SelectedServers.Find(host => host.IsMaster() && poolHosts.Contains(host)); if (master != null) { planActions.AddRange(CompileActionList(master, poolPatch)); } foreach (Host server in SelectedServers) { if (poolHosts.Contains(server)) { if (!server.IsMaster()) { // check patch isn't already applied here if (poolPatch == null || poolPatch.AppliedOn(server) == DateTime.MaxValue) { planActions.AddRange(CompileActionList(server, poolPatch)); } } } } if (RemoveUpdateFile) { planActions.Add(new RemoveUpdateFile(pool, poolPatch)); } } planActions.Add(new UnwindProblemsAction(ProblemsResolvedPreCheck)); actionsWorker = new BackgroundWorker(); actionsWorker.DoWork += new DoWorkEventHandler(PatchingWizardAutomaticPatchWork); actionsWorker.WorkerReportsProgress = true; actionsWorker.ProgressChanged += new ProgressChangedEventHandler(actionsWorker_ProgressChanged); actionsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(actionsWorker_RunWorkerCompleted); actionsWorker.WorkerSupportsCancellation = true; actionsWorker.RunWorkerAsync(planActions); }
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; } 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)); } } //iSL (StorageLink) check checks.Add(new KeyValuePair <string, List <Check> >(Messages.CHECKING_STORAGELINK_STATUS, new List <Check>())); checkGroup = checks[checks.Count - 1].Value; foreach (Host host in SelectedServers) { checkGroup.Add(new HostHasUnsupportedStorageLinkSRCheck(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); }