예제 #1
0
        protected override void RunWithSession(ref Session session)
        {
            AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATE, _patch.Name(), _pool.Name()));
            XenRef <Task> task = Pool_patch.async_pool_clean(session, _patch.opaque_ref);

            PollTaskForResultAndDestroy(Connection, ref session, task);
        }
        protected override void RunWithSession(ref Session session)
        {
            try
            {
                Pool_patch poolPatch = null;

                var mapping = patchMappings.FirstOrDefault(pm => pm.MasterHost != null && master != null &&
                                                           pm.MasterHost.uuid == master.uuid && pm.XenServerPatch.Equals(patch));

                if (mapping != null || mapping.Pool_patch != null && mapping.Pool_patch.opaque_ref != null)
                {
                    poolPatch = mapping.Pool_patch;
                }
                else
                {
                    poolPatch = session.Connection.Cache.Pool_patches.FirstOrDefault(pp => string.Equals(pp.uuid, patch.Uuid, System.StringComparison.InvariantCultureIgnoreCase));
                }

                if (poolPatch != null && poolPatch.opaque_ref != null)
                {
                    var task = Pool_patch.async_pool_clean(session, mapping.Pool_patch.opaque_ref);
                    PollTaskForResultAndDestroy(Connection, ref session, task);

                    patchMappings.Remove(mapping);
                }
            }
            catch (Exception ex)
            {
                //best effort
                log.Error("Failed to remove Pool_patch from the server.", ex);
            }
        }
예제 #3
0
        protected override void RunWithSession(ref Session session)
        {
            try
            {
                var existing = (from HostUpdateMapping hum in patchMappings
                                let xpm = hum as XenServerPatchMapping
                                          where xpm != null && xpm.Matches(master, xenServerPatch)
                                          select xpm).FirstOrDefault();

                if (!Helpers.ElyOrGreater(session.Connection))
                {
                    Pool_patch poolPatch = null;
                    var        mapping   = existing as PoolPatchMapping;

                    if (mapping != null && mapping.IsValid)
                    {
                        poolPatch = mapping.Pool_patch;
                    }
                    else
                    {
                        poolPatch = session.Connection.Cache.Pool_patches.FirstOrDefault(pp => string.Equals(pp.uuid, xenServerPatch.Uuid, StringComparison.InvariantCultureIgnoreCase));
                    }

                    if (poolPatch != null && poolPatch.opaque_ref != null)
                    {
                        AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolPatch.Name()));
                        var task = Pool_patch.async_pool_clean(session, mapping.Pool_patch.opaque_ref);
                        PollTaskForResultAndDestroy(Connection, ref session, task);

                        patchMappings.Remove(mapping);
                    }
                }
                else
                {
                    var mapping = existing as PoolUpdateMapping;

                    if (mapping != null && mapping.IsValid)
                    {
                        var poolUpdate = mapping.Pool_update;
                        AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolUpdate.Name()));

                        Pool_update.pool_clean(session, poolUpdate.opaque_ref);

                        if (!poolUpdate.AppliedOnHosts().Any())
                        {
                            Pool_update.destroy(session, poolUpdate.opaque_ref);
                        }

                        patchMappings.Remove(mapping);
                    }
                }
            }
            catch (Exception ex)
            {
                //best effort
                log.Error("Failed to remove update from the server.", ex);
            }
        }
예제 #4
0
        private AsyncAction GetCleanActionForPoolPatch(Pool_patch patch)
        {
            if (patch == null || patch.Connection == null || !patch.Connection.IsConnected)
            {
                return(null);
            }

            if (patch.HostsAppliedTo().Count == 0)
            {
                return(new RemovePatchAction(patch));
            }

            return(new DelegatedAsyncAction(patch.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_patch.async_pool_clean(session, patch.opaque_ref)));
        }
예제 #5
0
        private List <AsyncAction> GetRemovePatchActions(List <Pool_patch> patchesToRemove)
        {
            if (patchesToRemove == null)
            {
                return(null);
            }

            List <AsyncAction> list = new List <AsyncAction>();

            foreach (Pool_patch patch in patchesToRemove)
            {
                if (patch.Connection != null && patch.Connection.IsConnected)
                {
                    if (patch.HostsAppliedTo().Count == 0)
                    {
                        list.Add(new RemovePatchAction(patch));
                    }
                    else
                    {
                        list.Add(new DelegatedAsyncAction(patch.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_patch.async_pool_clean(session, patch.opaque_ref)));
                    }
                }
            }
            return(list);
        }
예제 #6
0
        protected override void RunWithSession(ref Session session)
        {
            XenRef <Task> task = Pool_patch.async_pool_clean(session, _patchRef.opaque_ref);

            PollTaskForResultAndDestroy(Connection, ref session, task);
        }