Search in sources :

Example 51 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class SecurityController method setApacheSSlEnabled.

@RequestMapping(value = "/ui/ssl/enabled/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApacheSSlEnabled(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody boolean enabled) {
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setApacheSslEnabled(deploymentName, enabled));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateApacheSsl(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    return DaemonTaskHandler.submitTask(builder::build, "Edit UI SSL settings");
}
Also used : UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class SecurityController method setApacheSSl.

@RequestMapping(value = "/ui/ssl/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApacheSSl(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApacheSsl) {
    ApacheSsl apacheSsl = objectMapper.convertValue(rawApacheSsl, ApacheSsl.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> apacheSsl.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setApacheSsl(deploymentName, apacheSsl));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateApacheSsl(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit UI SSL settings");
}
Also used : Path(java.nio.file.Path) ApacheSsl(com.netflix.spinnaker.halyard.config.model.v1.security.ApacheSsl) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class SecurityController method setApiSecurity.

@RequestMapping(value = "/api/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApiSecurity) {
    ApiSecurity apiSecurity = objectMapper.convertValue(rawApiSecurity, ApiSecurity.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> apiSecurity.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setApiSecurity(deploymentName, apiSecurity));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateApiSecurity(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit API security settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ApiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 54 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class ResponseUnwrapper method formatProblemSet.

private static void formatProblemSet(ProblemSet problemSet) {
    if (problemSet == null || problemSet.isEmpty()) {
        return;
    }
    AnsiSnippet snippet = new AnsiSnippet("\r").setErase(AnsiErase.ERASE_LINE);
    AnsiPrinter.err.print(snippet.toString());
    Map<String, List<Problem>> locationGroup = problemSet.groupByLocation();
    for (Entry<String, List<Problem>> entry : locationGroup.entrySet()) {
        AnsiUi.problemLocation(entry.getKey());
        for (Problem problem : entry.getValue()) {
            Severity severity = problem.getSeverity();
            String message = problem.getMessage();
            String remediation = problem.getRemediation();
            List<String> options = problem.getOptions();
            switch(severity) {
                case FATAL:
                case ERROR:
                    AnsiUi.error(message);
                    break;
                case WARNING:
                    AnsiUi.warning(message);
                    break;
                default:
                    throw new RuntimeException("Unknown severity level " + severity);
            }
            if (remediation != null && !remediation.isEmpty()) {
                AnsiUi.remediation(remediation);
            }
            if (options != null && !options.isEmpty()) {
                AnsiUi.remediation("Options include: ");
                options.forEach(AnsiUi::listRemediation);
            }
            // Newline between errors
            AnsiUi.raw("");
        }
    }
}
Also used : Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) Severity(com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity)

Example 55 with ProblemSet

use of com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet in project halyard by spinnaker.

the class DaemonTask method failure.

public void failure(Exception e) {
    inFailedState();
    fatalError = e;
    Problem problem = new ProblemBuilder(Problem.Severity.FATAL, "Unexpected exception: " + e).build();
    response = new DaemonResponse<>(null, new ProblemSet(problem));
}
Also used : Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Aggregations

ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)54 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)52 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)50 Path (java.nio.file.Path)37 DaemonResponse (com.netflix.spinnaker.halyard.core.DaemonResponse)3 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)2 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2 Cluster (com.netflix.spinnaker.halyard.config.model.v1.node.Cluster)2 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)2 Subscription (com.netflix.spinnaker.halyard.config.model.v1.node.Subscription)2 ApiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity)2 UiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)1 BakeryDefaults (com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1