protected override void RunWithSession(ref Session session)
        {
            var master = Helpers.GetMaster(Connection);
            var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid);

            if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null))
            {
                if (Cancelling)
                    throw new CancelledException();

                try
                {
                    AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, patch.Name, host.Name()));

                    PatchPrecheckCheck check = mapping.Pool_patch == null
                        ? new PatchPrecheckCheck(host, mapping.Pool_update)
                        : new PatchPrecheckCheck(host, mapping.Pool_patch);

                    var problems = check.RunAllChecks();

                    Diagnostics.Problems.Problem problem = null;

                    if (problems != null && problems.Count > 0)
                        problem = problems[0];

                    if (problem != null)
                        throw new Exception(string.Format("{0}: {1}. {2}", host, problem.Title, problem.Description));
                }
                catch (Exception ex)
                {
                    log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex);
                    throw;
                }
            }
        }
        protected override void RunWithSession(ref Session session)
        {
            var master  = Helpers.GetMaster(Connection);
            var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid);

            if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null))
            {
                var livePatchStatus = new Dictionary <string, livepatch_status>();

                if (Cancelling)
                {
                    throw new CancelledException();
                }

                try
                {
                    AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, patch.Name, host.Name()));

                    PatchPrecheckCheck check = mapping.Pool_patch == null
                        ? new PatchPrecheckCheck(host, mapping.Pool_update, livePatchStatus)
                        : new PatchPrecheckCheck(host, mapping.Pool_patch, livePatchStatus);

                    var problems = check.RunAllChecks();

                    Diagnostics.Problems.Problem problem = null;

                    if (problems != null && problems.Count > 0)
                    {
                        problem = problems[0];
                    }

                    if (problem != null)
                    {
                        throw new Exception(problem.Description);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex);
                    throw;
                }

                if (livePatchStatus.ContainsKey(host.uuid) &&
                    livePatchStatus[host.uuid] != livepatch_status.ok_livepatch_complete &&
                    !hostsThatWillRequireReboot.Contains(host.uuid))
                {
                    hostsThatWillRequireReboot.Add(host.uuid);
                }
            }
        }
        private void PrecheckSuppPack(Pool_update update, string suppPack, out bool alreadyApplied, out bool updateRequiresHostEvacuation)
        {
            alreadyApplied = false;
            if (Cancelling)
            {
                throw new CancelledException();
            }

            var livePatchStatus = new Dictionary <string, livepatch_status>();

            try
            {
                AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, suppPack, host.Name()));


                PatchPrecheckCheck check = new PatchPrecheckCheck(host, update, livePatchStatus);
                var problems             = check.RunAllChecks();
                updateRequiresHostEvacuation = WizardHelpers.IsHostRebootRequiredForUpdate(host, update, livePatchStatus);
                if (problems != null && problems.Count > 0)
                {
                    if (problems[0] is PatchAlreadyApplied)
                    {
                        log.InfoFormat("The update {0} is already applied on {1}. Ignore it.", suppPack, host.Name());
                        ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, suppPack, host.Name()));
                        alreadyApplied = true;
                    }
                    else
                    {
                        throw new Exception(problems[0].Description);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex);
                throw;
            }

            if (livePatchStatus.ContainsKey(host.uuid) &&
                livePatchStatus[host.uuid] != livepatch_status.ok_livepatch_complete &&
                !hostsThatWillRequireReboot.Contains(host.uuid))
            {
                hostsThatWillRequireReboot.Add(host.uuid);
            }
        }
Esempio n. 4
0
        protected override void RunWithSession(ref Session session)
        {
            var master  = Helpers.GetMaster(Connection);
            var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid);

            if (mapping != null && mapping.Pool_patch != null)
            {
                foreach (var host in hosts)
                {
                    if (Cancelling)
                    {
                        throw new CancelledException();
                    }

                    try
                    {
                        var check    = new PatchPrecheckCheck(host, mapping.Pool_patch);
                        var problems = check.RunAllChecks();

                        Diagnostics.Problems.Problem problem = null;

                        if (problems != null && problems.Count > 0)
                        {
                            problem = problems[0];
                        }

                        if (problem != null)
                        {
                            throw new Exception(string.Format("{0}: {1}. {2}", host, problem.Title, problem.Description));
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(string.Format("Precheck failed on host {0}", host.Name), ex);
                        throw ex;
                    }
                }
            }
        }