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