Beispiel #1
0
        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))
            {
                XenRef <Task> task = null;

                if (mapping.Pool_patch != null)
                {
                    task = Pool_patch.async_apply(session, mapping.Pool_patch.opaque_ref, host.opaque_ref);
                }
                else
                {
                    task = Pool_update.async_apply(session, mapping.Pool_update.opaque_ref, host.opaque_ref);
                }

                PollTaskForResultAndDestroy(Connection, ref session, task);
            }
            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.");
            }
        }
        private void ApplySuppPack(IXenConnection connection, Session session, string suppPack, Pool_update update, bool updateRequiresHostEvacuation)
        {
            try
            {
                // evacuate the host, if needed, before applying the update
                if (updateRequiresHostEvacuation)
                {
                    EvacuateHost(ref session);
                }

                AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, suppPack, host.Name()));

                var task = Pool_update.async_apply(session, update.opaque_ref, host.opaque_ref);
                PollTaskForResultAndDestroy(connection, ref session, task);
            }
            catch (Failure f)
            {
                if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == Failure.UPDATE_ALREADY_APPLIED)
                {
                    log.InfoFormat("The update {0} is already applied on {1}. Ignoring this error.", suppPack, host.Name());
                    ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, suppPack, host.Name()));
                }
                else
                {
                    throw;
                }
            }
        }
        protected override void Run()
        {
            SafeToExit = false;

            if (update.AppliedOn(host))
            {
                return;
            }

            Description = string.Format(Messages.APPLYING_PATCH, update.Name(), host.Name());
            log.Debug(Description);

            var poolUpdates = new List <Pool_update>(Connection.Cache.Pool_updates);
            var poolUpdate  = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase));

            if (poolUpdate == null)
            {
                throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_UPDATE_GONE);
            }

            if (!poolUpdate.AppliedOn(host))
            {
                RelatedTask = Pool_update.async_apply(Session, poolUpdate.opaque_ref, host.opaque_ref);
                PollToCompletion();
                Description = string.Format(Messages.PATCH_APPLIED, update.Name(), host.Name());
            }
            else
            {
                Description = string.Format(Messages.PATCH_APPLIED_ALREADY, update.Name(), host.Name());
            }
        }
Beispiel #4
0
        protected override void RunWithSession(ref Session session)
        {
            AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, _poolUpdate.Name(), _host.Name()));
            XenRef <Task> task = Pool_update.async_apply(session, _poolUpdate.opaque_ref, _host.opaque_ref);

            PollTaskForResultAndDestroy(Connection, ref session, task);
        }
        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.");
            }

            var host = GetResolvedHost();

            try
            {
                // evacuate the host, if needed, before applying the update
                if (mapping.HostsThatNeedEvacuated.Contains(host.uuid))
                {
                    EvacuateHost(ref session);
                }

                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;
                }
            }
        }
Beispiel #6
0
        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.");
            }
        }
Beispiel #7
0
        protected override void Run()
        {
            SafeToExit = false;

            if (update.AppliedOn(host))
            {
                return;
            }

            Description = string.Format(Messages.APPLYING_PATCH, update.Name(), host.Name());
            log.DebugFormat("Applying update '{0}' to server '{1}'...", update.Name(), host.Name());

            var poolUpdates = new List <Pool_update>(Connection.Cache.Pool_updates);
            var poolUpdate  = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase));

            if (poolUpdate == null)
            {
                throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_UPDATE_GONE);
            }

            if (poolUpdate.AppliedOn(host))
            {
                Description = string.Format(Messages.PATCH_APPLIED_ALREADY, update.Name(), host.Name());
                return;
            }

            try
            {
                RelatedTask = Pool_update.async_apply(Session, poolUpdate.opaque_ref, host.opaque_ref);
                PollToCompletion();
                Description = string.Format(Messages.PATCH_APPLIED, update.Name(), host.Name());
            }
            catch (Failure f)
            {
                log.ErrorFormat("Failed to apply update '{0}' on server '{1}': '{2}'",
                                update.Name(), host.Name(), string.Join(", ", f.ErrorDescription)); //CA-339237
                throw;
            }
        }
Beispiel #8
0
        protected override void RunWithSession(ref Session session)
        {
            XenRef <Task> task = Pool_update.async_apply(session, poolUpdate.opaque_ref, host.opaque_ref);

            PollTaskForResultAndDestroy(Connection, ref session, task);
        }