Ejemplo n.º 1
0
        public override void PageLoaded(PageLoadedDirection direction)
        {
            base.PageLoaded(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(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);
        }
Ejemplo n.º 2
0
        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(otherPatch.uuid == Patch.uuid);
                        }
                        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);
        }