Search in sources :

Example 16 with Provider

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

the class ProviderController method setProvider.

@RequestMapping(value = "/{providerName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setProvider(@PathVariable String deploymentName, @PathVariable String providerName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawProvider) {
    Provider provider = objectMapper.convertValue(rawProvider, Providers.translateProviderType(providerName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> provider.stageLocalFiles(configPath));
    builder.setUpdate(() -> providerService.setProvider(deploymentName, provider));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> providerService.validateProvider(deploymentName, providerName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the " + providerName + " provider");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with Provider

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

the class AbstractAddAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getAccountName();
    Account account = buildAccount(accountName);
    account.setRequiredGroupMembership(requiredGroupMembership);
    account.setProviderVersion(providerVersion);
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    new OperationHandler<Void>().setFailureMesssage("Failed to add account " + accountName + " for provider " + providerName + ".").setSuccessMessage("Successfully added account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.addAccount(currentDeployment, providerName, !noValidate, account)).get();
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 18 with Provider

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

the class AbstractEditAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getAccountName();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    Account account = new OperationHandler<Account>().setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.getAccount(currentDeployment, providerName, accountName, false)).get();
    int originaHash = account.hashCode();
    account = editAccount((T) account);
    account.setRequiredGroupMembership(updateStringList(account.getRequiredGroupMembership(), requiredGroupMembership, addRequiredGroupMembership, removeRequiredGroupMembership));
    account.setProviderVersion(isSet(providerVersion) ? providerVersion : account.getProviderVersion());
    if (originaHash == account.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit account " + accountName + " for provider " + providerName + ".").setSuccessMessage("Successfully edited account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.setAccount(currentDeployment, providerName, accountName, !noValidate, account)).get();
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 19 with Provider

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

the class AbstractAddBaseImageCommand method executeThis.

@Override
protected void executeThis() {
    String baseImageId = getBaseImageId();
    BaseImage baseImage = buildBaseImage(baseImageId);
    BaseImage.ImageSettings imageSettings = baseImage.getBaseImage();
    if (imageSettings == null) {
        throw new RuntimeException("Provider " + getProviderName() + " must provide image settings when building a base image. This is a bug with this provider's implementation of halyard.");
    }
    imageSettings.setId(getBaseImageId());
    imageSettings.setShortDescription(shortDescription);
    imageSettings.setDetailedDescription(detailedDescription);
    imageSettings.setPackageType(packageType);
    imageSettings.setTemplateFile(templateFile);
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    new OperationHandler<Void>().setSuccessMessage("Successfully added base image " + baseImageId + " to " + providerName + "'s bakery.").setFailureMesssage("Failed to add base image " + baseImageId + " to " + providerName + "'s bakery.").setOperation(Daemon.addBaseImage(currentDeployment, providerName, !noValidate, baseImage)).get();
}
Also used : BaseImage(com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 20 with Provider

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

the class AbstractListAccountsCommand method executeThis.

@Override
protected void executeThis() {
    Provider provider = getProvider();
    List<Account> accounts = provider.getAccounts();
    if (accounts.isEmpty()) {
        AnsiUi.success("No configured accounts for " + getProviderName() + ".");
    } else {
        AnsiUi.success("Accounts for " + getProviderName() + ":");
        accounts.forEach(account -> AnsiUi.listItem(account.getName()));
    }
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider)

Aggregations

Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)13 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)9 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)8 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)8 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)7 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)6 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)6 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)4 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)4 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)4 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)4 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)4 AwsProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider)4 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)4 DCOSCluster (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster)4 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)4 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)3 HasImageProvider (com.netflix.spinnaker.halyard.config.model.v1.node.HasImageProvider)3 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)3 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)3