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");
}
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();
}
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();
}
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();
}
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()));
}
}
Aggregations