Search in sources :

Example 1 with Features

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

the class EditFeaturesCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    Features features = new OperationHandler<Features>().setOperation(Daemon.getFeatures(currentDeployment, false)).setFailureMesssage("Failed to load features.").get();
    int originalHash = features.hashCode();
    features.setChaos(chaos != null ? chaos : features.isChaos());
    features.setJobs(jobs != null ? jobs : features.isJobs());
    features.setPipelineTemplates(pipelineTemplates != null ? pipelineTemplates : features.getPipelineTemplates());
    features.setArtifacts(artifacts != null ? artifacts : features.getArtifacts());
    features.setMineCanary(mineCanary != null ? mineCanary : features.getMineCanary());
    features.setInfrastructureStages(infrastructureStages != null ? infrastructureStages : features.getInfrastructureStages());
    if (originalHash == features.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setFeatures(currentDeployment, !noValidate, features)).setSuccessMessage("Successfully updated features.").setFailureMesssage("Failed to edit features.").get();
}
Also used : Features(com.netflix.spinnaker.halyard.config.model.v1.node.Features) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with Features

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

the class FeaturesController method setFeatures.

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

Example 3 with Features

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

the class DeckProfileFactory method setProfile.

@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
    StringResource configTemplate = new StringResource(profile.getBaseContents());
    UiSecurity uiSecurity = deploymentConfiguration.getSecurity().getUiSecurity();
    profile.setUser(ApacheSettings.APACHE_USER);
    Features features = deploymentConfiguration.getFeatures();
    Notifications notifications = deploymentConfiguration.getNotifications();
    Map<String, Object> bindings = new HashMap<>();
    String version = deploymentConfiguration.getVersion();
    // Configure global settings
    bindings.put("gate.baseUrl", endpoints.getServices().getGate().getBaseUrl());
    bindings.put("timezone", deploymentConfiguration.getTimezone());
    bindings.put("version", deploymentConfiguration.getVersion());
    Optional<Versions.Version> validatedVersion = versionsService.getVersions().getVersion(version);
    if (validatedVersion.isPresent()) {
        String changelog = validatedVersion.get().getChangelog();
        bindings.put("changelog.gist.id", changelog.substring(changelog.lastIndexOf("/") + 1));
        bindings.put("changelog.gist.name", "changelog.md");
    } else {
        bindings.put("changelog.gist.id", "");
        bindings.put("changelog.gist.name", "");
    }
    // Configure feature-flags
    bindings.put("features.auth", Boolean.toString(features.isAuth(deploymentConfiguration)));
    bindings.put("features.chaos", Boolean.toString(features.isChaos()));
    bindings.put("features.jobs", Boolean.toString(features.isJobs()));
    bindings.put("features.fiat", Boolean.toString(deploymentConfiguration.getSecurity().getAuthz().isEnabled()));
    bindings.put("features.pipelineTemplates", Boolean.toString(features.getPipelineTemplates() != null ? features.getPipelineTemplates() : false));
    bindings.put("features.artifacts", Boolean.toString(features.getArtifacts() != null ? features.getArtifacts() : false));
    bindings.put("features.mineCanary", Boolean.toString(features.getMineCanary() != null ? features.getMineCanary() : false));
    // Configure Kubernetes
    KubernetesProvider kubernetesProvider = deploymentConfiguration.getProviders().getKubernetes();
    bindings.put("kubernetes.default.account", kubernetesProvider.getPrimaryAccount());
    bindings.put("kubernetes.default.namespace", "default");
    bindings.put("kubernetes.default.proxy", "localhost:8001");
    // Configure GCE
    GoogleProvider googleProvider = deploymentConfiguration.getProviders().getGoogle();
    bindings.put("google.default.account", googleProvider.getPrimaryAccount());
    bindings.put("google.default.region", "us-central1");
    bindings.put("google.default.zone", "us-central1-f");
    // Configure Azure
    AzureProvider azureProvider = deploymentConfiguration.getProviders().getAzure();
    bindings.put("azure.default.account", azureProvider.getPrimaryAccount());
    bindings.put("azure.default.region", "westus");
    // Configure Appengine
    AppengineProvider appengineProvider = deploymentConfiguration.getProviders().getAppengine();
    bindings.put("appengine.default.account", appengineProvider.getPrimaryAccount());
    bindings.put("appengine.enabled", Boolean.toString(appengineProvider.getPrimaryAccount() != null));
    // Configure DC/OS
    final DCOSProvider dcosProvider = deploymentConfiguration.getProviders().getDcos();
    bindings.put("dcos.default.account", dcosProvider.getPrimaryAccount());
    // TODO(willgorman) need to set the proxy url somehow
    // Configure Openstack
    OpenstackProvider openstackProvider = deploymentConfiguration.getProviders().getOpenstack();
    bindings.put("openstack.default.account", openstackProvider.getPrimaryAccount());
    if (openstackProvider.getPrimaryAccount() != null) {
        OpenstackAccount openstackAccount = (OpenstackAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "openstack", openstackProvider.getPrimaryAccount());
        String firstRegion = openstackAccount.getRegions().get(0);
        bindings.put("openstack.default.region", firstRegion);
    }
    // Configure notifications
    bindings.put("notifications.enabled", notifications.isEnabled() + "");
    SlackNotification slackNotification = notifications.getSlack();
    bindings.put("notifications.slack.enabled", slackNotification.isEnabled() + "");
    bindings.put("notifications.slack.botName", slackNotification.getBotName());
    // Configure canary
    Canary canary = deploymentConfiguration.getCanary();
    bindings.put("canary.atlasWebComponentsUrl", canary.getAtlasWebComponentsUrl());
    bindings.put("canary.featureEnabled", Boolean.toString(canary.isEnabled()));
    if (canary.isEnabled()) {
        // TODO(duftler): Automatically choose the first metrics/storage/judge here if unspecified?
        bindings.put("canary.reduxLogger", canary.isReduxLoggerEnabled());
        bindings.put("canary.defaultMetricsAccount", canary.getDefaultMetricsAccount());
        bindings.put("canary.defaultStorageAccount", canary.getDefaultStorageAccount());
        bindings.put("canary.defaultJudge", canary.getDefaultJudge());
        bindings.put("canary.defaultMetricsStore", canary.getDefaultMetricsStore());
        bindings.put("canary.stages", canary.isStagesEnabled());
        bindings.put("canary.templatesEnabled", canary.isTemplatesEnabled());
        bindings.put("canary.showAllCanaryConfigs", canary.isShowAllConfigsEnabled());
    }
    profile.appendContents(configTemplate.setBindings(bindings).toString()).setRequiredFiles(backupRequiredFiles(uiSecurity, deploymentConfiguration.getName()));
}
Also used : HashMap(java.util.HashMap) AzureProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider) AppengineProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider) Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) StringResource(com.netflix.spinnaker.halyard.core.resource.v1.StringResource) KubernetesProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider) OpenstackProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider) UiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity) SlackNotification(com.netflix.spinnaker.halyard.config.model.v1.notifications.SlackNotification) DCOSProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider) Features(com.netflix.spinnaker.halyard.config.model.v1.node.Features) Notifications(com.netflix.spinnaker.halyard.config.model.v1.node.Notifications) GoogleProvider(com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider) OpenstackAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackAccount)

Example 4 with Features

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

the class FeaturesService method getFeatures.

public Features getFeatures(String deploymentName) {
    NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setFeatures();
    List<Features> matching = lookupService.getMatchingNodesOfType(filter, Features.class);
    switch(matching.size()) {
        case 0:
            Features features = new Features();
            setFeatures(deploymentName, features);
            return features;
        case 1:
            return matching.get(0);
        default:
            throw new RuntimeException("It shouldn't be possible to have multiple features nodes. This is a bug.");
    }
}
Also used : Features(com.netflix.spinnaker.halyard.config.model.v1.node.Features) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 5 with Features

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

the class FeaturesService method setFeatures.

public void setFeatures(String deploymentName, Features newFeatures) {
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    deploymentConfiguration.setFeatures(newFeatures);
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Aggregations

Features (com.netflix.spinnaker.halyard.config.model.v1.node.Features)4 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)1 Notifications (com.netflix.spinnaker.halyard.config.model.v1.node.Notifications)1 SlackNotification (com.netflix.spinnaker.halyard.config.model.v1.notifications.SlackNotification)1 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)1 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)1 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)1 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)1 KubernetesProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)1 OpenstackAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackAccount)1 OpenstackProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.openstack.OpenstackProvider)1 UiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 StringResource (com.netflix.spinnaker.halyard.core.resource.v1.StringResource)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1