Search in sources :

Example 11 with DeploymentTopologyDTO

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

the class DeploymentTopologyStepDefinitions method theDeploymentTopologyShouldNotHaveTheFollowingInputProperties.

@Then("^the deployment topology should not have the following input properties$")
public void theDeploymentTopologyShouldNotHaveTheFollowingInputProperties(List<String> expectedMissings) throws Throwable {
    DeploymentTopologyDTO dto = getDeploymentTopologyDTO();
    Set<String> actualInputs = safe(dto.getTopology().getAllInputProperties()).keySet();
    for (String expectedMissing : expectedMissings) {
        Assert.assertFalse("\"" + expectedMissing + "\" should not appear in inputs", actualInputs.contains(expectedMissing));
    }
}
Also used : DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) Then(cucumber.api.java.en.Then)

Example 12 with DeploymentTopologyDTO

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

the class DeploymentTopologyStepDefinitions method theDeploymentTopologyShouldNotHaveAnyInputProperties.

@Then("^the deployment topology should not have any input properties$")
public void theDeploymentTopologyShouldNotHaveAnyInputProperties() throws Throwable {
    DeploymentTopologyDTO dto = getDeploymentTopologyDTO();
    Assert.assertTrue(MapUtils.isEmpty(dto.getTopology().getAllInputProperties()));
}
Also used : DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) Then(cucumber.api.java.en.Then)

Example 13 with DeploymentTopologyDTO

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

the class DeploymentTopologyController method updateDeploymentSetup.

/**
 * @param appId The application id
 * @param environmentId Id of the environment we want to update
 * @param updateRequest an {@link UpdateDeploymentTopologyRequest} object
 * @return a {@link RestResponse} with:<br>
 *         the {@link DeploymentTopologyDTO} if everything went well, the <br>
 *         Error if not
 *
 * @throws OrchestratorDisabledException
 */
@ApiOperation(value = "Updates by merging the given request into the given application's deployment topology.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<?> updateDeploymentSetup(@PathVariable String appId, @PathVariable String environmentId, @RequestBody UpdateDeploymentTopologyRequest updateRequest) throws OrchestratorDisabledException {
    try {
        // check rights on related environment
        DeploymentTopologyDTO dto = execute(appId, environmentId, (application, environment, topologyVersion, topology) -> {
            // Set inputs
            inputService.setInputValues(environment, topology, updateRequest.getInputProperties());
            // Set orchestrator specific properties
            orchestratorPropertiesService.setOrchestratorProperties(environment, updateRequest.getProviderDeploymentProperties());
        });
        return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
    } catch (ConstraintTechnicalException e) {
        if (e.getCause() instanceof ConstraintFunctionalException) {
            ConstraintFunctionalException ex = (ConstraintFunctionalException) e.getCause();
            return RestConstraintValidator.fromException(ex, ex.getConstraintInformation().getName(), ex.getConstraintInformation().getValue());
        }
        throw e;
    }
}
Also used : ConstraintFunctionalException(org.alien4cloud.tosca.exceptions.ConstraintFunctionalException) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) ConstraintTechnicalException(org.alien4cloud.tosca.exceptions.ConstraintTechnicalException) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with DeploymentTopologyDTO

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

the class DeploymentTopologyController method updatePolicySubstitution.

/**
 * Update policy substitution.
 *
 * @param appId id of the application.
 * @param environmentId id of the environment.
 * @return response containing the deployment topology dto {@link DeploymentTopologyDTO}.
 */
@ApiOperation(value = "Substitute a specific policy by a location policy resource template in the topology of an application, given an environment.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/policies/{policyId}/substitution", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<DeploymentTopologyDTO> updatePolicySubstitution(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String policyId, @RequestParam String locationResourceTemplateId) {
    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());
    DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, () -> policyMatchingSubstitutionService.updateSubstitution(application, environment, topology, policyId, locationResourceTemplateId));
    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) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with DeploymentTopologyDTO

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

the class DeploymentTopologyController method updatePolicySubstitutionProperty.

@ApiOperation(value = "Update policy substitution's property.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/policies/{nodeId}/substitution/properties", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<?> updatePolicySubstitutionProperty(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String nodeId, @RequestBody UpdatePropertyRequest updateRequest) {
    try {
        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());
        DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, () -> matchedPolicyPropertiesConfigService.updateProperty(application, environment, topology, nodeId, updateRequest.getPropertyName(), updateRequest.getPropertyValue()));
        return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
    } catch (ConstraintTechnicalException e) {
        if (e.getCause() instanceof ConstraintFunctionalException) {
            return RestConstraintValidator.fromException((ConstraintFunctionalException) e.getCause(), updateRequest.getPropertyName(), updateRequest.getPropertyValue());
        }
        throw e;
    }
}
Also used : ConstraintFunctionalException(org.alien4cloud.tosca.exceptions.ConstraintFunctionalException) 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) ConstraintTechnicalException(org.alien4cloud.tosca.exceptions.ConstraintTechnicalException) ApplicationTopologyVersion(alien4cloud.model.application.ApplicationTopologyVersion) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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