Search in sources :

Example 6 with Halconfig

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

the class MetricStoresController method setMetricStore.

@RequestMapping(value = "/{metricStoreType:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMetricStore(@PathVariable String deploymentName, @PathVariable String metricStoreType, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMetricStore) {
    MetricStore metricStore = objectMapper.convertValue(rawMetricStore, MetricStores.translateMetricStoreType(metricStoreType));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path stagingPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> metricStore.stageLocalFiles(stagingPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> metricStoresService.setMetricStore(deploymentName, metricStore));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> metricStoresService.validateMetricStore(deploymentName, metricStoreType));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(stagingPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit " + metricStoreType + " metric store");
}
Also used : MetricStore(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore) Path(java.nio.file.Path) 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 7 with Halconfig

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

the class MetricStoresController method setMetricStores.

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMetricStores(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMetricStores) {
    MetricStores metricStores = objectMapper.convertValue(rawMetricStores, MetricStores.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> metricStores.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> metricStoresService.setMetricStores(deploymentName, metricStores));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> metricStoresService.validateMetricStores(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit all metric stores");
}
Also used : Path(java.nio.file.Path) MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) 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 8 with Halconfig

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

the class PersistentStorageController method setPersistentStorage.

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setPersistentStorage(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawPersistentStorage) {
    PersistentStorage persistentStorage = objectMapper.convertValue(rawPersistentStorage, PersistentStorage.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> persistentStorage.stageLocalFiles(configPath));
    builder.setUpdate(() -> persistentStorageService.setPersistentStorage(deploymentName, persistentStorage));
    builder.setSeverity(severity);
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> persistentStorageService.validatePersistentStorage(deploymentName);
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit persistent storage settings");
}
Also used : Path(java.nio.file.Path) PersistentStorage(com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStorage) 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 9 with Halconfig

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

the class SubscriptionController method addSubscription.

@RequestMapping(value = "/", method = RequestMethod.POST)
DaemonTask<Halconfig, Void> addSubscription(@PathVariable String deploymentName, @PathVariable String pubsubName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSubscription) {
    Subscription subscription = objectMapper.convertValue(rawSubscription, Pubsubs.translateSubscriptionType(pubsubName));
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    builder.setSeverity(severity);
    builder.setUpdate(() -> subscriptionService.addSubscription(deploymentName, pubsubName, subscription));
    Supplier<ProblemSet> doValidate = ProblemSet::new;
    if (validate) {
        doValidate = () -> subscriptionService.validateSubscription(deploymentName, pubsubName, subscription.getName());
    }
    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    return DaemonTaskHandler.submitTask(builder::build, "Add the " + subscription.getName() + " subscription");
}
Also used : UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) Subscription(com.netflix.spinnaker.halyard.config.model.v1.node.Subscription) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Halconfig

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

the class DeploymentEnvironmentController method setDeploymentEnvironment.

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

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)36 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)35 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)33 Path (java.nio.file.Path)33 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)11 Halconfig (com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)9 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)7 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)6 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)5 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)5 IOException (java.io.IOException)5 Node (com.netflix.spinnaker.halyard.config.model.v1.node.Node)4 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)3 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)3 List (java.util.List)3 ParseConfigException (com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2