Search in sources :

Example 1 with Providers

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

the class ClouddriverBootstrapProfileFactory method disableAllProviders.

private void disableAllProviders(Providers providers) {
    NodeIterator providerNodes = providers.getChildren();
    Provider provider;
    while ((provider = (Provider) providerNodes.getNext()) != null) {
        provider.setEnabled(false);
    }
}
Also used : NodeIterator(com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)

Example 2 with Providers

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

the class ProviderService method getProvider.

public Provider getProvider(String deploymentName, String providerName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName);
    List<Provider> matching = lookupService.getMatchingNodesOfType(filter, Provider.class);
    switch(matching.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No provider with name \"" + providerName + "\" could be found").setRemediation("Create a new provider with name \"" + providerName + "\"").build());
        case 1:
            return matching.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one provider with name \"" + providerName + "\" found").setRemediation("Manually delete or rename duplicate providers with name \"" + providerName + "\" 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) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException) GoogleProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider) AzureProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider) AwsProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider) AppengineProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) OracleBMCSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.oraclebmcs.OracleBMCSProvider) OpenstackProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider) DCOSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider) KubernetesProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)

Example 3 with Providers

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

the class ArtifactProviderService method getAllArtifactProviders.

public List<ArtifactProvider> getAllArtifactProviders(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyArtifactProvider();
    List<ArtifactProvider> matching = lookupService.getMatchingNodesOfType(filter, ArtifactProvider.class);
    if (matching.size() == 0) {
        throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No providers could be found").build());
    } else {
        return matching;
    }
}
Also used : GitHubArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.github.GitHubArtifactProvider) ArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider) HttpArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider) GcsArtifactProvider(com.netflix.spinnaker.halyard.config.model.v1.artifacts.gcs.GcsArtifactProvider) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 4 with Providers

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

the class ClouddriverProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    super.setProfile(profile, deploymentConfiguration, endpoints);
    // We need to make modifications to this deployment configuration, but can't use helpful objects
    // like the accountService on a clone. Therefore, we'll make the modifications in place and
    // restore to the original state when the modifications are written out.
    Providers originalProviders = deploymentConfiguration.getProviders().cloneNode(Providers.class);
    Providers modifiedProviders = deploymentConfiguration.getProviders();
    DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
    if (deploymentEnvironment.getBootstrapOnly() != null && deploymentEnvironment.getBootstrapOnly()) {
        String bootstrapAccountName = deploymentEnvironment.getAccountName();
        removeBootstrapOnlyAccount(modifiedProviders, deploymentConfiguration.getName(), bootstrapAccountName);
    }
    Artifacts artifacts = deploymentConfiguration.getArtifacts();
    List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName());
    files.addAll(backupRequiredFiles(artifacts, deploymentConfiguration.getName()));
    if (deploymentConfiguration.getProviders() != null) {
        processProviders(deploymentConfiguration.getProviders());
    }
    profile.appendContents(yamlToString(modifiedProviders)).appendContents(yamlToString(new ArtifactWrapper(artifacts))).appendContents(profile.getBaseContents()).setRequiredFiles(files);
    deploymentConfiguration.setProviders(originalProviders);
}
Also used : Artifacts(com.netflix.spinnaker.halyard.config.model.v1.node.Artifacts) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) Providers(com.netflix.spinnaker.halyard.config.model.v1.node.Providers)

Example 5 with Providers

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

the class ClouddriverProfileFactory method removeBootstrapOnlyAccount.

@SuppressWarnings("unchecked")
private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) {
    Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
    Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent());
    bootstrapProvider.getAccounts().remove(bootstrapAccount);
    if (bootstrapProvider.getAccounts().isEmpty()) {
        bootstrapProvider.setEnabled(false);
        if (bootstrapAccount instanceof ContainerAccount) {
            ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
            DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers);
            containerAccount.getDockerRegistries().forEach(reg -> {
                Set<Account> dependentAccounts = revIndex.get(reg.getAccountName());
                if (dependentAccounts == null || dependentAccounts.isEmpty()) {
                    DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName());
                    ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct);
                }
            });
            if (providers.getDockerRegistry().getAccounts().isEmpty()) {
                providers.getDockerRegistry().setEnabled(false);
            }
        }
    }
}
Also used : ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) ContainerAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount) DockerRegistryAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount) DockerRegistryProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider)

Aggregations

ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)4 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)4 Providers (com.netflix.spinnaker.halyard.config.model.v1.node.Providers)4 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)4 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)4 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)3 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)3 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)2 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 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)2 ContainerAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.containers.ContainerAccount)2 DockerRegistryAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount)2 ArtifactSourcesConfig (com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig)1 Artifacts (com.netflix.spinnaker.halyard.config.model.v1.node.Artifacts)1 Cis (com.netflix.spinnaker.halyard.config.model.v1.node.Cis)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1