示例#1
0
        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
            {
                var result        = Pool_patch.precheck(session, Patch.opaque_ref, Host.opaque_ref);
                var livePatchCode = TryToFindLivePatchCode(result);

                if (livePatchCodesByHost != null)
                {
                    livePatchCodesByHost[Host.uuid] = livePatchCode;
                }

                return(FindProblem(result));
            }
            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));
            }
        }
示例#2
0
        public 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), Host));
            }
            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]);
                }
                return(new PrecheckFailed(this, Host, f));
            }
        }
示例#3
0
        private Dictionary <Pool, StringBuilder> ModePoolPatch(out bool someHostMayRequireRestart)
        {
            someHostMayRequireRestart = false;

            if (Patch == null || Patch.after_apply_guidance == null || Patch.after_apply_guidance.Count == 0)
            {
                return(null);
            }

            var applicableServers = SelectedServers.Where(h => Patch.AppliedOn(h) == DateTime.MaxValue).ToList();
            var serversPerPool    = GroupServersPerPool(SelectedPools, applicableServers);

            var total = new Dictionary <Pool, StringBuilder>();

            foreach (var guide in Patch.after_apply_guidance)
            {
                var result = GetGuidanceList(guide, serversPerPool, null, out someHostMayRequireRestart);
                if (result == null)
                {
                    continue;
                }
                foreach (var kvp in result)
                {
                    if (total.ContainsKey(kvp.Key))
                    {
                        total[kvp.Key].Append(kvp.Value).AppendLine();
                    }
                    else
                    {
                        total[kvp.Key] = kvp.Value;
                    }
                }
            }

            return(total);
        }
示例#4
0
        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));
            }
        }
示例#5
0
        protected override Problem RunCheck()
        {
            //
            // Check that the SR where the update was uploaded is still attached
            //
            if (srUploadedUpdates != null &&
                ((srUploadedUpdates.shared && !srUploadedUpdates.CanBeSeenFrom(Host)) ||
                 (!srUploadedUpdates.shared && srUploadedUpdates.IsBroken())))
            {
                return(new BrokenSRWarning(this, Host, srUploadedUpdates));
            }

            //
            // 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));
            }

            if (!Host.IsLive())
            {
                return(new HostNotLiveWarning(this, Host));
            }

            if (!Host.Connection.IsConnected)
            {
                throw new EndOfStreamException(Helpers.GetName(Host.Connection));
            }

            Session session = Host.Connection.DuplicateSession();



            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;
                    }
                }
                //trying to apply update to partially upgraded pool
                else if (Helpers.ElyOrGreater(Helpers.GetMaster(Host.Connection)) && !Helpers.ElyOrGreater(Host))
                {
                    return(new WrongServerVersion(this, Host));
                }

                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));
            }
        }