Search in sources :

Example 21 with NodeFilter

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.

the class DeploymentService method getDeploymentConfiguration.

public DeploymentConfiguration getDeploymentConfiguration(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName);
    List<DeploymentConfiguration> matching = lookupService.getMatchingNodesOfType(filter, DeploymentConfiguration.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No deployment with name \"" + deploymentName + "\" could be found").setRemediation("Create a new deployment with name \"" + deploymentName + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one deployment with name \"" + deploymentName + "\" found").setRemediation("Manually delete or rename duplicate deployments with name \"" + deploymentName + "\" in your halconfig file").build());
    }
}
Also used : ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 22 with NodeFilter

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.

the class DeploymentService method validateDeployment.

public ProblemSet validateDeployment(String deploymentName) {
    PersistentStorage storage = storageService.getPersistentStorage(deploymentName);
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyProvider().withAnyAccount().setFeatures().setSecurity();
    if (storage.getPersistentStoreType() != null) {
        filter.setPersistentStore(storage.getPersistentStoreType().getId());
    }
    return validateService.validateMatchingFilter(filter);
}
Also used : PersistentStorage(com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStorage) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 23 with NodeFilter

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.

the class MetricStoresService method getMetricStores.

public MetricStores getMetricStores(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores();
    List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class);
    switch(matching.size()) {
        case 0:
            MetricStores metricStores = new MetricStores();
            setMetricStores(deploymentName, metricStores);
            return metricStores;
        case 1:
            return matching.get(0);
        default:
            throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug.");
    }
}
Also used : MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 24 with NodeFilter

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.

the class MetricStoresService method getMetricStore.

public MetricStore getMetricStore(String deploymentName, String metricStoreType) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores().setMetricStore(metricStoreType);
    List<MetricStore> matching = lookupService.getMatchingNodesOfType(filter, MetricStore.class);
    try {
        switch(matching.size()) {
            case 0:
                MetricStore metricStores = MetricStores.translateMetricStoreType(metricStoreType).newInstance();
                setMetricStore(deploymentName, metricStores);
                return metricStores;
            case 1:
                return matching.get(0);
            default:
                throw new RuntimeException("It shouldn't be possible to have multiple metricStore nodes of the same type. This is a bug.");
        }
    } catch (InstantiationException | IllegalAccessException e) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Can't create an empty metric store node " + "for metricStore type \"" + metricStoreType + "\"").build());
    }
}
Also used : MetricStore(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 25 with NodeFilter

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter in project halyard by spinnaker.

the class OptionsService method options.

public <T extends Node> FieldOptions options(NodeFilter filter, Class<T> nodeClass, String field) {
    ConfigProblemSetBuilder problemSetBuilder = new ConfigProblemSetBuilder(applicationContext);
    List<T> nodes = lookupService.getMatchingNodesOfType(filter, nodeClass);
    List<String> options = nodes.stream().map(n -> {
        problemSetBuilder.setNode(n);
        return n.fieldOptions(problemSetBuilder, field);
    }).reduce(new ArrayList<>(), (a, b) -> {
        a.addAll(b);
        return a;
    });
    return new FieldOptions().setOptions(options).setProblemSet(problemSetBuilder.build());
}
Also used : Component(org.springframework.stereotype.Component) List(java.util.List) Data(lombok.Data) DaemonResponse(com.netflix.spinnaker.halyard.core.DaemonResponse) Autowired(org.springframework.beans.factory.annotation.Autowired) Node(com.netflix.spinnaker.halyard.config.model.v1.node.Node) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) ConfigProblemSetBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder) ApplicationContext(org.springframework.context.ApplicationContext) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter) ArrayList(java.util.ArrayList) ConfigProblemSetBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)

Aggregations

NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)26 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)20 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)17 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)9 Node (com.netflix.spinnaker.halyard.config.model.v1.node.Node)3 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)3 PersistentStorage (com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStorage)3 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)3 AwsProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider)3 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)3 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)3 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)3 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)3 KubernetesProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)3 OpenstackProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider)3 OracleBMCSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.oraclebmcs.OracleBMCSProvider)3 GcsArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider)2 GitHubArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider)2 HttpArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2