Search in sources :

Example 26 with OperationHandler

use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler 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 27 with OperationHandler

use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.

the class AbstractEditBaseImageCommand method executeThis.

@Override
protected void executeThis() {
    String baseImageId = getBaseImageId();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    BaseImage baseImage = new OperationHandler<BaseImage>().setFailureMesssage("Failed to get base image " + baseImageId + " in" + providerName + "'s bakery.").setOperation(Daemon.getBaseImage(currentDeployment, providerName, baseImageId, false)).get();
    int originalHash = baseImage.hashCode();
    BaseImage.ImageSettings imageSettings = baseImage.getBaseImage();
    if (imageSettings == null) {
        throw new RuntimeException("Image settings cannot be deleted during an edit. This is a bug in the " + getProviderName() + " provider's implementation of halyard.");
    }
    imageSettings.setId(isSet(id) ? id : imageSettings.getId());
    imageSettings.setShortDescription(isSet(shortDescription) ? shortDescription : imageSettings.getShortDescription());
    imageSettings.setDetailedDescription(isSet(detailedDescription) ? detailedDescription : imageSettings.getDetailedDescription());
    imageSettings.setPackageType(isSet(packageType) ? packageType : imageSettings.getPackageType());
    imageSettings.setTemplateFile(isSet(templateFile) ? templateFile : imageSettings.getTemplateFile());
    baseImage = editBaseImage((T) baseImage);
    if (originalHash == baseImage.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit base image " + baseImageId + " in" + providerName + "'s bakery.").setSuccessMessage("Successfully edited base image " + baseImageId + " in" + providerName + "'s bakery.").setOperation(Daemon.setBaseImage(currentDeployment, providerName, baseImageId, !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 28 with OperationHandler

use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.

the class AbstractPersistentStoreEditCommand method executeThis.

@Override
protected void executeThis() {
    String persistentStoreType = getPersistentStoreType();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    PersistentStore persistentStore = new OperationHandler<PersistentStore>().setFailureMesssage("Failed to get persistent store \"" + persistentStoreType + "\".").setOperation(Daemon.getPersistentStore(currentDeployment, persistentStoreType, false)).get();
    int originalHash = persistentStore.hashCode();
    persistentStore = editPersistentStore((T) persistentStore);
    if (originalHash == persistentStore.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit persistent store \"" + persistentStoreType + "\".").setSuccessMessage("Successfully edited persistent store \"" + persistentStoreType + "\".").setOperation(Daemon.setPersistentStore(currentDeployment, persistentStoreType, !noValidate, persistentStore)).get();
}
Also used : PersistentStore(com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStore) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 29 with OperationHandler

use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.

the class DCOSEditClusterCommand method executeThis.

@Override
protected void executeThis() {
    String clusterName = getClusterName();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    DCOSCluster cluster = (DCOSCluster) new OperationHandler<Cluster>().setFailureMesssage("Failed to get cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.getCluster(currentDeployment, providerName, clusterName, false)).get();
    int originalHash = cluster.hashCode();
    if (!isStringEmpty(dcosUrl)) {
        cluster.setDcosUrl(dcosUrl);
    }
    if (!isStringEmpty(caCertFile)) {
        cluster.setCaCertFile(caCertFile);
    }
    if (removeCaCertFile) {
        cluster.setCaCertFile(null);
    }
    if (Objects.nonNull(insecureSkipTlsVerify)) {
        cluster.setInsecureSkipTlsVerify(insecureSkipTlsVerify);
    }
    if (!isStringEmpty(loadBalancerImage)) {
        DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
        if (loadBalancer == null) {
            loadBalancer = new DCOSCluster.LoadBalancer();
            cluster.setLoadBalancer(loadBalancer);
        }
        loadBalancer.setImage(loadBalancerImage);
    }
    if (!isStringEmpty(loadBalancerServiceAccountSecret)) {
        DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
        if (loadBalancer == null) {
            loadBalancer = new DCOSCluster.LoadBalancer();
            cluster.setLoadBalancer(loadBalancer);
        }
        loadBalancer.setServiceAccountSecret(loadBalancerServiceAccountSecret);
    }
    if (removeLoadBalancer) {
        cluster.setLoadBalancer(null);
    }
    if (originalHash == cluster.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit cluster " + clusterName + " for provider " + providerName + ".").setSuccessMessage("Successfully edited cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.setCluster(currentDeployment, providerName, clusterName, !noValidate, cluster)).get();
}
Also used : DCOSCluster(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 30 with OperationHandler

use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.

the class EditCanaryAwsCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    Canary canary = new OperationHandler<Canary>().setFailureMesssage("Failed to get canary.").setOperation(Daemon.getCanary(currentDeployment, false)).get();
    int originalHash = canary.hashCode();
    AwsCanaryServiceIntegration awsCanaryServiceIntegration = (AwsCanaryServiceIntegration) CanaryUtils.getServiceIntegrationByClass(canary, AwsCanaryServiceIntegration.class);
    awsCanaryServiceIntegration.setS3Enabled(isSet(s3Enabled) ? s3Enabled : awsCanaryServiceIntegration.isS3Enabled());
    if (awsCanaryServiceIntegration.isS3Enabled()) {
        awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE));
        awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
    } else {
        awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE));
        awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
    }
    if (originalHash == canary.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)).setFailureMesssage("Failed to edit canary analysis AWS service integration settings.").setSuccessMessage("Successfully edited canary analysis AWS service integration settings.").get();
}
Also used : Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) AwsCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.aws.AwsCanaryServiceIntegration) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Aggregations

OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)38 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)6 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 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)2 Subscription (com.netflix.spinnaker.halyard.config.model.v1.node.Subscription)2 DCOSCluster (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster)2 Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)2 AbstractCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration)1 AwsCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.aws.AwsCanaryServiceIntegration)1 GoogleCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration)1 PrometheusCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.prometheus.PrometheusCanaryServiceIntegration)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 Features (com.netflix.spinnaker.halyard.config.model.v1.node.Features)1 MetricStore (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore)1 MetricStores (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores)1