Esempio n. 1
0
        private List <HostPlan> CompileManualHostPlan(Pool pool, out List <Host> applicableHosts)
        {
            var poolHosts = pool.Connection.Cache.Hosts.ToList();

            SelectedServers.Sort(); //master first and then the slaves
            var hostplans = new List <HostPlan>();

            if (SelectedUpdateType == UpdateType.ISO)
            {
                if (PoolUpdate != null) //ely or greater
                {
                    foreach (var server in SelectedServers)
                    {
                        if (poolHosts.Contains(server))
                        {
                            var updateActions = new List <PlanAction> {
                                new ApplyPoolUpdatePlanAction(server, PoolUpdate)
                            };
                            hostplans.Add(new HostPlan(server, null, updateActions, null));
                        }
                    }
                }
                else if (SuppPackVdis != null) //supp pack
                {
                    foreach (var server in SelectedServers)
                    {
                        if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server))
                        {
                            var updateActions = new List <PlanAction> {
                                new InstallSupplementalPackPlanAction(server, SuppPackVdis[server])
                            };
                            hostplans.Add(new HostPlan(server, null, updateActions, null));
                        }
                    }
                }
            }
            else // legacy
            {
                foreach (var server in SelectedServers)
                {
                    if (poolHosts.Contains(server))
                    {
                        var updateActions = new List <PlanAction> {
                            new ApplyPatchPlanAction(server, Patch)
                        };
                        hostplans.Add(new HostPlan(server, null, updateActions, null));
                    }
                }

                if (RemoveUpdateFile && hostplans.Count > 0)
                {
                    hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, Patch));
                }
            }

            applicableHosts = hostplans.Select(h => h.Host).ToList();
            return(hostplans);
        }
Esempio n. 2
0
        private List <PlanAction> CompileSuppPackActionList(Host host)
        {
            List <PlanAction> actions = new List <PlanAction>();

            if (SelectedUpdateType != UpdateType.ISO || SuppPackVdis == null || !SuppPackVdis.ContainsKey(host))
            {
                return(actions);
            }

            actions.Add(new InstallSupplementalPackPlanAction(host, SuppPackVdis[host]));

            // after_apply_guidance is restartHost
            actions.Add(new RestartHostPlanAction(host, host.GetRunningVMs()));

            return(actions);
        }
Esempio n. 3
0
        private List <PlanAction> CompileSuppPackActionList(Host host)
        {
            List <PlanAction> actions = new List <PlanAction>();

            if (SelectedUpdateType != UpdateType.ISO || SuppPackVdis == null || !SuppPackVdis.ContainsKey(host))
            {
                return(actions);
            }

            List <XenRef <VM> > runningVMs = RunningVMs(host);

            actions.Add(new InstallSupplementalPackPlanAction(host, SuppPackVdis[host]));

            // after_apply_guidance is restartHost
            actions.Add(new EvacuateHostPlanAction(host));
            actions.Add(new RebootHostPlanAction(host));
            actions.Add(new BringBabiesBackAction(runningVMs, host, false));

            return(actions);
        }
Esempio n. 4
0
        private List <HostPlan> CompileAutomaticHostPlan(Pool pool, out List <Host> applicableHosts)
        {
            var poolHosts = pool.Connection.Cache.Hosts.ToList();

            SelectedServers.Sort(); //master first and then the slaves
            var hostplans = new List <HostPlan>();

            if (SelectedUpdateType == UpdateType.ISO)
            {
                var poolUpdates = new List <Pool_update>(pool.Connection.Cache.Pool_updates);
                var poolUpdate  = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, PoolUpdate.uuid, StringComparison.OrdinalIgnoreCase));

                if (poolUpdate != null) //ely or greater
                {
                    foreach (var server in SelectedServers)
                    {
                        if (poolHosts.Contains(server) && !poolUpdate.AppliedOn(server))
                        {
                            hostplans.Add(new HostPlan(server, null, CompilePoolUpdateActionList(server, poolUpdate), null));
                        }
                    }
                }
                else if (SuppPackVdis != null) // supp pack
                {
                    foreach (var server in SelectedServers)
                    {
                        if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server))
                        {
                            var updateActions = new List <PlanAction>
                            {
                                new InstallSupplementalPackPlanAction(server, SuppPackVdis[server]),
                                new RestartHostPlanAction(server, server.GetRunningVMs())
                            };
                            hostplans.Add(new HostPlan(server, null, updateActions, null));
                        }
                    }
                }
            }
            else //legacy
            {
                var poolPatches = new List <Pool_patch>(pool.Connection.Cache.Pool_patches);
                var poolPatch   = poolPatches.Find(p => Patch != null && string.Equals(p.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase));

                if (poolPatch != null)
                {
                    foreach (Host server in SelectedServers)
                    {
                        if (poolHosts.Contains(server) && poolPatch.AppliedOn(server) == DateTime.MaxValue)
                        {
                            hostplans.Add(new HostPlan(server, null, CompilePatchActionList(server, poolPatch), null));
                        }
                    }
                }

                if (RemoveUpdateFile && hostplans.Count > 0)
                {
                    hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, poolPatch));
                }
            }

            applicableHosts = hostplans.Select(h => h.Host).ToList();
            return(hostplans);
        }