Skip to content

Commit

Permalink
remove references to terraform in central deployment orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopar committed Jan 18, 2024
1 parent be874a0 commit ec06cd0
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 254 deletions.
10 changes: 5 additions & 5 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ maven/mavencentral/com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/2.15.3, Apache
maven/mavencentral/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/2.15.3, Apache-2.0, approved, #9101
maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jaxb-annotations/2.15.3, Apache-2.0, approved, #9100
maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.3, Apache-2.0, approved, #8803
maven/mavencentral/com.fasterxml.uuid/java-uuid-generator/4.0.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.fasterxml.uuid/java-uuid-generator/4.3.0, Apache-2.0, approved, #12790
maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.github.ben-manes.caffeine/caffeine/3.1.8, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.github.fge/btf/1.2, Apache-2.0 OR LGPL-2.0-or-later, approved, CQ14455
Expand All @@ -28,10 +28,10 @@ maven/mavencentral/com.google.errorprone/error_prone_annotations/2.1.3, Apache-2
maven/mavencentral/com.google.errorprone/error_prone_annotations/2.21.1, Apache-2.0, approved, #9834
maven/mavencentral/com.google.guava/guava/24.1.1-jre, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.google.j2objc/j2objc-annotations/1.1, Apache-2.0, approved, CQ18765
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-ces/3.1.76, Apache-2.0, approved, #12601
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-core/3.1.76, Apache-2.0, approved, #11922
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-ecs/3.1.76, Apache-2.0, approved, #12599
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-iam/3.1.76, Apache-2.0, approved, #12598
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-ces/3.1.77, Apache-2.0, approved, #12601
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-core/3.1.77, Apache-2.0, approved, #11922
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-ecs/3.1.77, Apache-2.0, approved, #12599
maven/mavencentral/com.huaweicloud.sdk/huaweicloud-sdk-iam/3.1.77, Apache-2.0, approved, #12598
maven/mavencentral/com.jayway.jsonpath/json-path/2.8.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.networknt/json-schema-validator/1.1.0, Apache-2.0 AND Unicode-TOU, approved, #12437
maven/mavencentral/com.nimbusds/content-type/2.3, Apache-2.0, approved, clearlydefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.xpanse.modules.database.service.DeployServiceEntity;
import org.eclipse.xpanse.modules.deployment.DeployService;
import org.eclipse.xpanse.modules.deployment.DeployServiceEntityHandler;
import org.eclipse.xpanse.modules.deployment.DeployerKindManager;
import org.eclipse.xpanse.modules.deployment.ServiceDetailsViewManager;
import org.eclipse.xpanse.modules.models.response.Response;
import org.eclipse.xpanse.modules.models.service.common.enums.Category;
Expand All @@ -40,7 +39,6 @@
import org.eclipse.xpanse.modules.models.service.view.VendorHostedDeployedServiceDetails;
import org.eclipse.xpanse.modules.models.workflow.migrate.MigrateRequest;
import org.eclipse.xpanse.modules.orchestrator.deployment.DeployTask;
import org.eclipse.xpanse.modules.orchestrator.deployment.Deployment;
import org.eclipse.xpanse.modules.security.IdentityProviderManager;
import org.eclipse.xpanse.modules.workflow.consts.MigrateConstants;
import org.eclipse.xpanse.modules.workflow.utils.WorkflowProcessUtils;
Expand Down Expand Up @@ -82,9 +80,6 @@ public class ServiceDeployerApi {
@Resource
private ServiceDetailsViewManager serviceDetailsViewManager;

@Resource
private DeployerKindManager deployerKindManager;

@Resource
private DeployServiceEntityHandler deployServiceEntityHandler;

Expand Down Expand Up @@ -168,10 +163,7 @@ public UUID deploy(@Valid @RequestBody DeployRequest deployRequest) {
Optional<String> userIdOptional = identityProviderManager.getCurrentLoginUserId();
deployRequest.setUserId(userIdOptional.orElse(null));
DeployTask deployTask = this.deployService.createNewDeployTask(deployRequest);
Deployment deployment =
this.deployerKindManager.getDeployment(
deployTask.getOcl().getDeployment().getKind());
this.deployService.deployService(deployment, deployTask);
this.deployService.deployService(deployTask);
String successMsg = String.format(
"Task for starting managed service %s-%s-%s-%s started. UUID %s",
deployRequest.getServiceName(),
Expand Down Expand Up @@ -203,10 +195,7 @@ public Response destroy(@PathVariable("id") String id) {
"No permissions to destroy services belonging to other users.");
}
DeployTask destroyTask = this.deployService.getDestroyTask(deployServiceEntity);
Deployment deployment =
this.deployerKindManager.getDeployment(
destroyTask.getOcl().getDeployment().getKind());
this.deployService.destroyService(deployment, destroyTask, deployServiceEntity);
this.deployService.destroyService(destroyTask, deployServiceEntity);
String successMsg = String.format(
"Task for destroying managed service %s has started.", id);
return Response.successResponse(Collections.singletonList(successMsg));
Expand All @@ -232,10 +221,7 @@ public Response purge(@PathVariable("id") String id) {
"No permissions to purge services belonging to other users.");
}
DeployTask purgeTask = this.deployService.getPurgeTask(deployServiceEntity);
Deployment deployment =
this.deployerKindManager.getDeployment(
purgeTask.getOcl().getDeployment().getKind());
this.deployService.asyncPurgeService(deployment, purgeTask, deployServiceEntity);
this.deployService.asyncPurgeService(purgeTask, deployServiceEntity);
String successMsg = String.format("Purging task for service with ID %s has started.", id);
return Response.successResponse(Collections.singletonList(successMsg));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.xpanse.modules.deployment.DeploymentResultCallbackManager;
import org.eclipse.xpanse.modules.deployment.deployers.terraform.TerraformDeploymentResultCallbackManager;
import org.eclipse.xpanse.modules.deployment.deployers.terraform.terraformboot.model.TerraformResult;
import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
Expand All @@ -25,31 +25,34 @@
import org.springframework.web.bind.annotation.RestController;

/**
* Webhook class for terraform-boot.
* Webhook class for terraform-boot. These API methods are not exposed to the end user.
* They are only for machine-to-machine communication.
* This class implements the callback methods described in the terraform-boot specifications.
*/
@Slf4j
@RestController
@Profile("terraform-boot")
@CrossOrigin
public class WebhookApi {
public class TerraformBootWebhookApi {


@Resource
private DeploymentResultCallbackManager deploymentResultCallbackManager;
private TerraformDeploymentResultCallbackManager terraformDeploymentResultCallbackManager;

/**
* Webhook methods to receive terraform execution result.
*/
@Tag(name = "Webhook", description = "Webhook APIs")
@Operation(description = "Process the execution result after terraform executes the command "
+ "line.")
@PostMapping(value = "${webhook.deployCallbackUri}{task_id}", produces =
@PostMapping(value = "${webhook.deployCallbackUri}/{task_id}", produces =
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public void deployCallback(
@Parameter(name = "task_id", description = "task id")
@PathVariable("task_id") String taskId, @Valid @RequestBody TerraformResult result) {

deploymentResultCallbackManager.deployCallback(taskId, result);
terraformDeploymentResultCallbackManager.deployCallback(taskId, result);
}

/**
Expand All @@ -58,13 +61,13 @@ public void deployCallback(
@Tag(name = "Webhook", description = "Webhook APIs")
@Operation(description = "Process the execution result after terraform executes the command "
+ "line.")
@PostMapping(value = "${webhook.destroyCallbackUri}{task_id}", produces =
@PostMapping(value = "${webhook.destroyCallbackUri}/{task_id}", produces =
MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public void destroyCallback(
@Parameter(name = "task_id", description = "task id") @PathVariable("task_id")
String taskId, @Valid @RequestBody TerraformResult result) {
deploymentResultCallbackManager.destroyCallback(taskId, result);
terraformDeploymentResultCallbackManager.destroyCallback(taskId, result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public class DeployServiceEntity extends CreateModifiedTime {
private Map<String, String> properties;

/**
* The properties of the deployed service.
* The private properties of the deployed service. This is not returned to the customer.
* This can be used by the deployer for storing any internal data.
*/
@ElementCollection
@CollectionTable(name = "DEPLOY_RESULT_PROPERTY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.eclipse.xpanse.modules.database.service.DeployServiceEntity;
import org.eclipse.xpanse.modules.models.service.deploy.DeployResource;
import org.eclipse.xpanse.modules.models.service.deploy.DeployResult;
import org.eclipse.xpanse.modules.models.service.deploy.enums.DeployerTaskStatus;
import org.eclipse.xpanse.modules.models.service.deploy.enums.ServiceDeploymentState;
import org.eclipse.xpanse.modules.models.service.deploy.enums.TerraformExecState;
import org.eclipse.xpanse.modules.models.service.manager.ServiceState;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -50,7 +50,7 @@ public DeployServiceEntity updateDeployServiceEntityWithDeployResult(
log.info("Deploy task update deploy service entity with id:{}", deployResult.getId());
DeployServiceEntity deployServiceEntityToFlush = new DeployServiceEntity();
BeanUtils.copyProperties(storedEntity, deployServiceEntityToFlush);
if (TerraformExecState.DEPLOY_SUCCESS == deployResult.getState()) {
if (DeployerTaskStatus.DEPLOY_SUCCESS == deployResult.getState()) {
deployServiceEntityToFlush.setServiceDeploymentState(
ServiceDeploymentState.DEPLOY_SUCCESS);
deployServiceEntityToFlush.setServiceState(ServiceState.RUNNING);
Expand Down Expand Up @@ -132,7 +132,7 @@ public DeployServiceEntity updateDeployServiceEntityWithDestroyResult(
DeployServiceEntity deployServiceEntityToFlush = new DeployServiceEntity();
BeanUtils.copyProperties(deployServiceEntity, deployServiceEntityToFlush);
if (isCalledWhenRollback) {
if (destroyResult.getState() == TerraformExecState.DESTROY_SUCCESS) {
if (destroyResult.getState() == DeployerTaskStatus.DESTROY_SUCCESS) {
deployServiceEntityToFlush.setServiceDeploymentState(
ServiceDeploymentState.DEPLOY_FAILED);
deployServiceEntityToFlush.setServiceState(ServiceState.NOT_RUNNING);
Expand All @@ -142,7 +142,7 @@ public DeployServiceEntity updateDeployServiceEntityWithDestroyResult(
deployServiceEntityToFlush.setServiceState(ServiceState.RUNNING);
}
} else {
if (destroyResult.getState() == TerraformExecState.DESTROY_SUCCESS) {
if (destroyResult.getState() == DeployerTaskStatus.DESTROY_SUCCESS) {
deployServiceEntityToFlush.setServiceDeploymentState(
ServiceDeploymentState.DESTROY_SUCCESS);
deployServiceEntityToFlush.setServiceState(ServiceState.NOT_RUNNING);
Expand Down

0 comments on commit ec06cd0

Please sign in to comment.