Пример #1
0
        private void ApplyPatch(Host host, Pool_patch patch)
        {
            // Set the correct connection object, for RecomputeCanCancel
            Connection = host.Connection;
            Session session = host.Connection.DuplicateSession();

            XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch);

            try
            {
                this.Description = String.Format(Messages.APPLYING_PATCH, patch.Name, host.Name);

                output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name, host.Name);
                output += Pool_patch.apply(session, patchRef, host.opaque_ref);

                this.Description = String.Format(Messages.PATCH_APPLIED, patch.Name, host.Name);
            }
            catch (Failure f)
            {
                if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED)
                {
                    output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE;
                    output += f.ErrorDescription[1];
                }

                throw;
            }
            finally
            {
                Connection = null;
            }
        }
Пример #2
0
        private void UploadAndApplyPatch(Host host, Session session)
        {
            var patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID);

            if (patch == null)
            {
                var master   = Helpers.GetMaster(host.Connection);
                var filePath = Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update));
                var action   = new Actions.UploadPatchAction(master.Connection, filePath);
                action.RunExternal(session);
                patch = action.PatchRefs[master];
            }
            Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref);
        }
Пример #3
0
        protected override void Run()
        {
            SafeToExit = false;

            if (patch.AppliedOn(host) != DateTime.MaxValue)
            {
                return;
            }

            XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch);

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

            var result = Pool_patch.apply(Session, patchRef, host.opaque_ref);

            log.DebugFormat(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name(), result);
            Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name());
        }
Пример #4
0
        public sealed override void Apply(Host host, Session session)
        {
            Pool_patch patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID);

            if (patch == null)
            {
                var master = Helpers.GetMaster(host.Connection);
                var action = new Actions.UploadPatchAction(master.Connection, Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update)));
                action.RunExternal(session);
                patch = action.PatchRefs[master];
            }
            Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref);

            int numberRetries = 0;

            do
            {
                Thread.Sleep(500);
                patch = host.Connection.Cache.Find_By_Uuid <Pool_patch>(UUID);
                numberRetries++;
            } while (patch == null && numberRetries < 10);
        }
Пример #5
0
        private void ApplyPatch()
        {
            XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch);

            try
            {
                this.Description = String.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name());

                output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name());
                output += Pool_patch.apply(Session, patchRef, host.opaque_ref);

                this.Description = String.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name());
            }
            catch (Failure f)
            {
                if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED)
                {
                    output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE;
                    output += f.ErrorDescription[1];
                }

                throw;
            }
        }