use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class ApplicationDeploymentController method getRuntimeTopology.
/**
* Get runtime topology of an application on a specific environment or the current deployment topology if no deployment is active.
* This method is necessary for example to compute output properties / attributes on the client side.
*
* @param applicationId application id for which to get the topology
* @param applicationEnvironmentId application environment for which to get the topology
* @return {@link RestResponse}<{@link TopologyDTO}> containing the requested runtime {@link Topology} and the
* {@link NodeType} related to its {@link NodeTemplate}s
*/
@ApiOperation(value = "Get last runtime (deployed) topology of an application or else get the current deployment topology for the environment.")
@RequestMapping(value = "/{applicationId:.+?}/environments/{applicationEnvironmentId:.+?}/runtime-topology", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> getRuntimeTopology(@ApiParam(value = "Id of the application for which to get deployed topology.", required = true) @PathVariable String applicationId, @ApiParam(value = "Id of the environment for which to get deployed topology.", required = true) @PathVariable String applicationEnvironmentId) {
ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Unable to find environment with id <" + applicationEnvironmentId + "> for application <" + applicationId + ">");
}
AuthorizationUtil.checkAuthorizationForEnvironment(applicationService.getOrFail(applicationId), environment, ApplicationEnvironmentRole.APPLICATION_USER);
Deployment deployment = deploymentService.getActiveDeployment(environment.getId());
DeploymentTopology deploymentTopology = null;
if (deployment != null) {
deploymentTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
}
return RestResponseBuilder.<TopologyDTO>builder().data(topologyDTOBuilder.initTopologyDTO(deploymentTopology, new TopologyDTO())).build();
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class EditorStepDefs method i_Recover_The_Topology.
@When("^I recover the topology$")
public void i_Recover_The_Topology() throws Throwable {
thrownException = null;
try {
TopologyDTO dto = editorService.recover(topologyIds.getLast(), topologyIdToLastOperationId.get(topologyIds.getLast()));
topologyIdToLastOperationId.put(topologyIds.getLast(), null);
dtoEvaluationContext = new StandardEvaluationContext(dto);
topologyEvaluationContext = new StandardEvaluationContext(dto.getTopology());
} catch (Exception e) {
log.error("Error occurred when recovering the topology", e);
thrownException = e;
exceptionEvaluationContext = new StandardEvaluationContext(e);
}
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method buildPaaSTopology.
/**
* Build the topology for deployment on the PaaS.
*
* @param topology The topology.
* @return The parsed topology for the PaaS with.
*/
@ToscaContextual
public PaaSTopology buildPaaSTopology(Topology topology) {
PaaSTopology paaSTopology = buildPaaSTopology(buildPaaSNodeTemplates(topology));
// Reuse this utility to query all types and inject them in the PaaSTopology
TopologyDTO topologyDTO = topologyDTOBuilder.initTopologyDTO(topology, new TopologyDTO());
paaSTopology.setDataTypes(topologyDTO.getDataTypes());
paaSTopology.setCapabilityTypes(topologyDTO.getCapabilityTypes());
paaSTopology.setRelationshipTypes(topologyDTO.getRelationshipTypes());
paaSTopology.setNodeTypes(topologyDTO.getNodeTypes());
return paaSTopology;
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class RuntimeController method getDeployedTopology.
/**
* Get runtime (deployed) topology of an application on a specific environment
*
* @param applicationId application id for which to get the topology
* @param applicationEnvironmentId application environment for which to get the topology through the version
* @return {@link RestResponse}<{@link TopologyDTO}> containing the requested runtime {@link Topology} and the
* {@link NodeType} related to his {@link NodeTemplate}s
*/
@ApiOperation(value = "Get runtime (deployed) topology of an application on a specific cloud.")
@RequestMapping(value = "/{applicationId:.+?}/environment/{applicationEnvironmentId:.+?}/topology", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> getDeployedTopology(@ApiParam(value = "Id of the application for which to get deployed topology.", required = true) @PathVariable String applicationId, @ApiParam(value = "Id of the environment for which to get deployed topology.", required = true) @PathVariable String applicationEnvironmentId) {
ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Unable to find environment with id <" + applicationEnvironmentId + "> for application <" + applicationId + ">");
}
// Security check user must be authorized to deploy the environment (or be application manager)
AuthorizationUtil.checkAuthorizationForEnvironment(applicationService.getOrFail(applicationId), environment);
Deployment deployment = deploymentService.getActiveDeploymentOrFail(environment.getId());
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
return RestResponseBuilder.<TopologyDTO>builder().data(topologyDTOBuilder.initTopologyDTO(deploymentTopology, new TopologyDTO())).build();
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class ApplicationStepDefinitions method The_created_application_topology_is_the_same_as_the_one_in_the_base_topology_template.
@Then("^The created application topology is the same as the one in the base topology template$")
public void The_created_application_topology_is_the_same_as_the_one_in_the_base_topology_template() throws Throwable {
// created topology
String topologyId = Csar.createId(CURRENT_APPLICATION.getId(), VersionUtil.DEFAULT_VERSION_NAME);
Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/topologies/" + topologyId));
TopologyDTO createdTopology = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
// base topology template
// quick win solution
authSteps.I_am_authenticated_with_role("ARCHITECT");
String topoResponse = Context.getRestClientInstance().get("/rest/v1/catalog/topologies/" + TopologyTemplateStepDefinitions.CURRENT_TOPOLOGY_TEMP_ID);
Topology topologyTemplateBase = JsonUtil.read(topoResponse, Topology.class, Context.getJsonMapper()).getData();
Map<String, NodeTemplate> nodeTemplates = topologyTemplateBase.getNodeTemplates();
// node templates count test
assertEquals(createdTopology.getTopology().getNodeTemplates().size(), nodeTemplates.size());
// node templates name / type test
for (Map.Entry<String, NodeTemplate> entry : createdTopology.getTopology().getNodeTemplates().entrySet()) {
assertTrue(nodeTemplates.containsKey(entry.getKey()));
assertTrue(nodeTemplates.get(entry.getKey()).getType().equals(entry.getValue().getType()));
}
}
Aggregations