protected override async Task Execute() { var provider = new HealthStatusProvider(Repository, Log, statuses, healthStatuses); var environmentResources = await GetEnvironments().ConfigureAwait(false); IEnumerable<MachineResource> environmentMachines = await FilterByEnvironments(environmentResources).ConfigureAwait(false); environmentMachines = FilterByState(environmentMachines, provider); LogFilteredMachines(environmentMachines, provider, environmentResources); }
protected override void Execute() { var provider = new HealthStatusProvider(Repository, Log, statuses, healthStatuses); var environmentResources = GetEnvironments(); var environmentMachines = FilterByEnvironments(environmentResources); environmentMachines = FilterByState(environmentMachines, provider); LogFilteredMachines(environmentMachines, provider, environmentResources); }
private void LogFilteredMachines(IEnumerable<MachineResource> environmentMachines, HealthStatusProvider provider, List<EnvironmentResource> environmentResources) { var orderedMachines = environmentMachines.OrderBy(m => m.Name).ToList(); Log.Information("Machines: {Count}", orderedMachines.Count); foreach (var machine in orderedMachines) { Log.Information(" - {Machine:l} {Status:l} (ID: {MachineId:l}) in {Environments:l}", machine.Name, provider.GetStatus(machine), machine.Id, string.Join(" and ", machine.EnvironmentIds.Select(id => environmentResources.First(e => e.Id == id).Name))); } }
protected override async Task Execute() { var provider = new HealthStatusProvider(Repository, Log, statuses, healthStatuses); var environmentResources = await GetEnvironments().ConfigureAwait(false); IEnumerable <MachineResource> environmentMachines = await FilterByEnvironments(environmentResources).ConfigureAwait(false); environmentMachines = FilterByState(environmentMachines, provider); LogFilteredMachines(environmentMachines, provider, environmentResources); }
private IEnumerable<MachineResource> FilterByState(IEnumerable<MachineResource> environmentMachines) { var provider = new HealthStatusProvider(Repository, Log, statuses, healthStatuses); environmentMachines = provider.Filter(environmentMachines); if (isDisabled.HasValue) { environmentMachines = environmentMachines.Where(m => m.IsDisabled == isDisabled.Value); } if (isCalamariOutdated.HasValue) { environmentMachines = environmentMachines.Where(m => m.HasLatestCalamari == !isCalamariOutdated.Value); } if (isTentacleOutdated.HasValue) { environmentMachines = environmentMachines.Where(m => (m.Endpoint as ListeningTentacleEndpointResource)?.TentacleVersionDetails.UpgradeSuggested == isTentacleOutdated.Value); } return environmentMachines; }
private IEnumerable <MachineResource> FilterByState(IEnumerable <MachineResource> environmentMachines) { var provider = new HealthStatusProvider(Repository, Log, statuses, healthStatuses); environmentMachines = provider.Filter(environmentMachines); if (isDisabled.HasValue) { environmentMachines = environmentMachines.Where(m => m.IsDisabled == isDisabled.Value); } if (isCalamariOutdated.HasValue) { environmentMachines = environmentMachines.Where(m => m.HasLatestCalamari == !isCalamariOutdated.Value); } if (isTentacleOutdated.HasValue) { environmentMachines = environmentMachines.Where(m => (m.Endpoint as ListeningTentacleEndpointResource)?.TentacleVersionDetails.UpgradeSuggested == isTentacleOutdated.Value); } return(environmentMachines); }
private void LogFilteredMachines(IEnumerable <MachineResource> environmentMachines, HealthStatusProvider provider, List <EnvironmentResource> environmentResources) { var orderedMachines = environmentMachines.OrderBy(m => m.Name).ToList(); Log.Information("Machines: {Count}", orderedMachines.Count); foreach (var machine in orderedMachines) { Log.Information(" - {Machine:l} {Status:l} (ID: {MachineId:l}) in {Environments:l}", machine.Name, provider.GetStatus(machine), machine.Id, string.Join(" and ", machine.EnvironmentIds.Select(id => environmentResources.First(e => e.Id == id).Name))); } }