use of alien4cloud.model.application.ApplicationTopologyVersion in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method execute.
private DeploymentTopologyDTO execute(String applicationId, String environmentId, IDeploymentConfigAction action) {
Application application = applicationService.getOrFail(applicationId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
// This method prepares the deployment and create a Deployment Topology DTO object.
return deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment, topologyVersion, action);
}
use of alien4cloud.model.application.ApplicationTopologyVersion in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method getDeploymentTopology.
/**
* Get the deployment topology of an application given an environment
*
* @param appId application Id
* @param environmentId environment Id
* @return the deployment topology DTO
*/
@ApiOperation(value = "Get the deployment topology of an application given an environment.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<DeploymentTopologyDTO> getDeploymentTopology(@PathVariable String appId, @PathVariable String environmentId) {
Application application = applicationService.getOrFail(appId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
// This method prepares the deployment and create a Deployment Topology DTO object.
DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment);
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
}
use of alien4cloud.model.application.ApplicationTopologyVersion in project alien4cloud by alien4cloud.
the class ApplicationDeploymentController method deploy.
/**
* Trigger deployment of the application on the current configured PaaS.
*
* @param deployApplicationRequest application details for deployment (applicationId + deploymentProperties)
* @return An empty rest response.
*/
@ApiOperation(value = "Deploys the application on the configured Cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/deployment", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit(bodyHiddenFields = { "secretProviderCredentials" })
public RestResponse<?> deploy(@Valid @RequestBody DeployApplicationRequest deployApplicationRequest) {
String applicationId = deployApplicationRequest.getApplicationId();
String environmentId = deployApplicationRequest.getApplicationEnvironmentId();
Application application = applicationService.checkAndGetApplication(applicationId);
ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, environmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Unable to find environment with id <" + environmentId + "> for application <" + applicationId + ">");
}
// Security check user must be authorized to deploy the environment (or be application manager)
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
// ensure deployment status is sync with underlying orchestrator
applicationEnvironmentService.getStatus(environment);
// check that the environment is not already deployed
boolean isEnvironmentDeployed = applicationEnvironmentService.isDeployed(environment.getId());
if (isEnvironmentDeployed) {
throw new AlreadyExistException("Environment with id <" + environmentId + "> for application <" + applicationId + "> is already deployed");
}
// prepare the deployment
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
return toscaContextualAspect.execInToscaContext(() -> doDeploy(deployApplicationRequest, application, environment, topology), false, topology);
}
Aggregations