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));
}
}
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()));
}
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;
}
}
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();
}
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;
}
}
Aggregations