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