Search in sources :

Example 16 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO 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();
}
Also used : DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Topology(org.alien4cloud.tosca.model.templates.Topology) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) ApplicationTopologyVersion(alien4cloud.model.application.ApplicationTopologyVersion) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method The_deployment_topology_shoud_have_the_following_location_policies.

@Then("^the deployment topology shoud have the following location policies$")
public void The_deployment_topology_shoud_have_the_following_location_policies(DataTable expectedSettings) throws Throwable {
    String response = Context.getInstance().getRestResponse();
    RestResponse<DeploymentTopologyDTO> deploymentTopologyDTO = JsonUtil.read(response, DeploymentTopologyDTO.class, Context.getJsonMapper());
    assertNotNull(deploymentTopologyDTO.getData());
    Map<String, String> policies = deploymentTopologyDTO.getData().getLocationPolicies();
    assertNotNull(policies);
    Context context = Context.getInstance();
    List<LocationPolicySetting> expectedLocationPoliciesSettings = convert(expectedSettings);
    for (LocationPolicySetting expected : expectedLocationPoliciesSettings) {
        String expectLocationId = context.getLocationId(context.getOrchestratorId(expected.getOrchestratorName()), expected.getLocationName());
        assertEquals(expectLocationId, policies.get(expected.getGroupName()));
    }
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) Then(cucumber.api.java.en.Then)

Example 18 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method getDTOAndassertNotNull.

private DeploymentTopologyDTO getDTOAndassertNotNull() throws IOException {
    String response = Context.getInstance().getRestResponse();
    DeploymentTopologyDTO dto = JsonUtil.read(response, DeploymentTopologyDTO.class, Context.getJsonMapper()).getData();
    assertNotNull(dto);
    return dto;
}
Also used : DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO)

Example 19 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters.

@And("^The deployment topology should have an input property \"([^\"]*)\" with the following parameters$")
public void theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters(String propertyName, Map<String, String> parameters) throws Throwable {
    DeploymentTopologyDTO dto = getDeploymentTopologyDTO();
    FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) safe(dto.getTopology().getAllInputProperties()).get(propertyName);
    Assert.assertEquals(functionPropertyValue.getFunction(), parameters.get("functionName"));
    Assert.assertEquals(functionPropertyValue.getParameters().get(0), parameters.get("secretPath"));
}
Also used : FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) And(cucumber.api.java.en.And)

Example 20 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method checkSubstitutions.

private void checkSubstitutions(List<SubstitutionSetting> expectedSubstitutionSettings, ITemplateSubstitutionInfoAccessor substitutionsAccessor) throws IOException {
    DeploymentTopologyDTO dto = getDTOAndassertNotNull();
    Map<String, String> substitutions = substitutionsAccessor.getSubstitutions(dto);
    Map<String, ? extends AbstractLocationResourceTemplate> resources = substitutionsAccessor.getSubstitutionTemplates(dto);
    assertTrue(MapUtils.isNotEmpty(substitutions));
    assertTrue(MapUtils.isNotEmpty(resources));
    for (SubstitutionSetting substitutionSetting : expectedSubstitutionSettings) {
        String substituteId = substitutions.get(substitutionSetting.getTemplateNme());
        assertNotNull(substituteId);
        AbstractLocationResourceTemplate substitute = resources.get(substituteId);
        assertNotNull(substitute);
        assertEquals(substitutionSetting.getResourceName(), substitute.getName());
        assertEquals(substitutionSetting.getResourceType(), substitute.getTemplate().getType());
    }
}
Also used : AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO)

Aggregations

DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)27 Then (cucumber.api.java.en.Then)13 Application (alien4cloud.model.application.Application)8 ApiOperation (io.swagger.annotations.ApiOperation)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)7 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)7 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)7 Topology (org.alien4cloud.tosca.model.templates.Topology)7 Audit (alien4cloud.audit.annotation.Audit)6 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)5 ConstraintFunctionalException (org.alien4cloud.tosca.exceptions.ConstraintFunctionalException)4 ConstraintTechnicalException (org.alien4cloud.tosca.exceptions.ConstraintTechnicalException)4 FunctionPropertyValue (org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)3 Context (alien4cloud.it.Context)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)2 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)2 RestError (alien4cloud.rest.model.RestError)2 RestResponse (alien4cloud.rest.model.RestResponse)2