use of com.netflix.spinnaker.halyard.config.model.v1.node.Provider in project halyard by spinnaker.
the class DCOSEditClusterCommand method executeThis.
@Override
protected void executeThis() {
String clusterName = getClusterName();
String providerName = getProviderName();
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
DCOSCluster cluster = (DCOSCluster) new OperationHandler<Cluster>().setFailureMesssage("Failed to get cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.getCluster(currentDeployment, providerName, clusterName, false)).get();
int originalHash = cluster.hashCode();
if (!isStringEmpty(dcosUrl)) {
cluster.setDcosUrl(dcosUrl);
}
if (!isStringEmpty(caCertFile)) {
cluster.setCaCertFile(caCertFile);
}
if (removeCaCertFile) {
cluster.setCaCertFile(null);
}
if (Objects.nonNull(insecureSkipTlsVerify)) {
cluster.setInsecureSkipTlsVerify(insecureSkipTlsVerify);
}
if (!isStringEmpty(loadBalancerImage)) {
DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
if (loadBalancer == null) {
loadBalancer = new DCOSCluster.LoadBalancer();
cluster.setLoadBalancer(loadBalancer);
}
loadBalancer.setImage(loadBalancerImage);
}
if (!isStringEmpty(loadBalancerServiceAccountSecret)) {
DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
if (loadBalancer == null) {
loadBalancer = new DCOSCluster.LoadBalancer();
cluster.setLoadBalancer(loadBalancer);
}
loadBalancer.setServiceAccountSecret(loadBalancerServiceAccountSecret);
}
if (removeLoadBalancer) {
cluster.setLoadBalancer(null);
}
if (originalHash == cluster.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit cluster " + clusterName + " for provider " + providerName + ".").setSuccessMessage("Successfully edited cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.setCluster(currentDeployment, providerName, clusterName, !noValidate, cluster)).get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Provider 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);
}
}
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Provider in project halyard by spinnaker.
the class ClouddriverBootstrapProfileFactory method setProfile.
@Override
@SuppressWarnings("unchecked")
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
super.setProfile(profile, deploymentConfiguration, endpoints);
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
if (deploymentEnvironment.getType() != DeploymentEnvironment.DeploymentType.Distributed) {
throw new IllegalStateException("There is no need to produce a bootstrapping clouddriver for a non-remote deployment of Spinnaker. This is a bug.");
}
// 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();
String deploymentName = deploymentConfiguration.getName();
String bootstrapAccountName = deploymentEnvironment.getAccountName();
Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
bootstrapAccount.makeBootstrappingAccount(artifactSourcesConfig);
Provider bootstrapProvider = (Provider) bootstrapAccount.getParent();
disableAllProviders(modifiedProviders);
bootstrapProvider.setEnabled(true);
bootstrapProvider.setAccounts(Collections.singletonList(bootstrapAccount));
if (bootstrapAccount instanceof ContainerAccount) {
ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
List<DockerRegistryAccount> bootstrapRegistries = containerAccount.getDockerRegistries().stream().map(ref -> (DockerRegistryAccount) accountService.getProviderAccount(deploymentName, DOCKER_REGISTRY, ref.getAccountName())).collect(Collectors.toList());
DockerRegistryProvider dockerProvider = modifiedProviders.getDockerRegistry();
dockerProvider.setEnabled(true);
dockerProvider.setAccounts(bootstrapRegistries);
}
if (bootstrapAccount instanceof SupportsConsul) {
SupportsConsul consulAccount = (SupportsConsul) bootstrapAccount;
ConsulConfig config = consulAccount.getConsul();
if (config == null) {
config = new ConsulConfig();
consulAccount.setConsul(config);
}
consulAccount.getConsul().setEnabled(true);
} else {
log.warn("Attempting to perform a distributed deployment to account \"" + bootstrapAccount.getName() + "\" without a discovery mechanism");
}
List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName());
profile.appendContents(yamlToString(modifiedProviders)).appendContents("services.fiat.enabled: false").appendContents(profile.getBaseContents()).setRequiredFiles(files);
deploymentConfiguration.setProviders(originalProviders);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Provider in project halyard by spinnaker.
the class RoscoProfileFactory method setProfile.
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
super.setProfile(profile, deploymentConfiguration, endpoints);
Providers providers = deploymentConfiguration.getProviders();
Providers otherProviders = getImageProviders(profile.getVersion());
NodeIterator iterator = providers.getChildren();
Provider child = (Provider) iterator.getNext();
while (child != null) {
if (child instanceof HasImageProvider) {
NodeIterator otherIterator = otherProviders.getChildren();
NodeFilter providerFilter = new NodeFilter().setProvider(child.getNodeName());
HasImageProvider otherChild = (HasImageProvider) otherIterator.getNext(providerFilter);
if (otherChild == null) {
log.warn("images.yml has no images stored for " + child.getNodeName());
} else {
log.info("Adding default images for " + child.getNodeName());
((HasImageProvider) child).getBakeryDefaults().addDefaultImages(otherChild.getBakeryDefaults().getBaseImages());
}
}
child = (Provider) iterator.getNext();
}
List<String> files = backupRequiredFiles(providers, deploymentConfiguration.getName());
profile.appendContents(yamlToString(providers)).appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Provider in project halyard by spinnaker.
the class AbstractArtifactEditAccountCommand method executeThis.
@Override
protected void executeThis() {
String accountName = getArtifactAccountName();
String providerName = getArtifactProviderName();
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
ArtifactAccount account = new OperationHandler<ArtifactAccount>().setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.getArtifactAccount(currentDeployment, providerName, accountName, false)).get();
int originaHash = account.hashCode();
account = editArtifactAccount((T) account);
if (originaHash == account.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit artifact account " + accountName + " for artifact provider " + providerName + ".").setSuccessMessage("Successfully edited artifact account " + accountName + " for artifact provider " + providerName + ".").setOperation(Daemon.setArtifactAccount(currentDeployment, providerName, accountName, !noValidate, account)).get();
}
Aggregations