use of alien4cloud.model.application.ApplicationEnvironment in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method updateSubstitutionProperty.
@ApiOperation(value = "Update node substitution's property.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/substitutions/{nodeId}/properties", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<?> updateSubstitutionProperty(@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, () -> matchedNodePropertiesConfigService.updateProperty(application, environment, topology, nodeId, Optional.empty(), 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;
}
}
use of alien4cloud.model.application.ApplicationEnvironment in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method updateSubstitution.
/**
* Update node substitution.
*
* @param appId id of the application.
* @param environmentId id of the environment.
* @return response containing the available substitutions.
*/
@ApiOperation(value = "Substitute a specific node by the location 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 = "/substitutions/{nodeId}", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<DeploymentTopologyDTO> updateSubstitution(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String nodeId, @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, () -> nodeMatchingSubstitutionService.updateSubstitution(application, environment, topology, nodeId, locationResourceTemplateId));
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
}
use of alien4cloud.model.application.ApplicationEnvironment in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method updateSubstitutionCapabilityProperty.
@ApiOperation(value = "Update substitution's capability property.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/substitutions/{nodeId}/capabilities/{capabilityName}/properties", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<?> updateSubstitutionCapabilityProperty(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String nodeId, @PathVariable String capabilityName, @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, () -> matchedNodePropertiesConfigService.updateProperty(application, environment, topology, nodeId, Optional.of(capabilityName), 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;
}
}
use of alien4cloud.model.application.ApplicationEnvironment in project alien4cloud by alien4cloud.
the class TopologyLocationMatchingController method match.
@ApiOperation(value = "Retrieve the list of locations on which the current user can deploy the topology.")
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<List<ILocationMatch>> match(@PathVariable String topologyId, @RequestParam(required = false) String environmentId) {
List<ILocationMatch> matchedLocation;
if (StringUtils.isNotBlank(environmentId)) {
ApplicationEnvironment environment = applicationEnvironmentService.getOrFail(environmentId);
Application application = applicationService.getOrFail(environment.getApplicationId());
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.DEPLOYMENT_MANAGER);
matchedLocation = locationMatchingService.match(topologyId, environment);
} else {
matchedLocation = locationMatchingService.match(topologyId, null);
}
return RestResponseBuilder.<List<ILocationMatch>>builder().data(matchedLocation).build();
}
use of alien4cloud.model.application.ApplicationEnvironment in project alien4cloud by alien4cloud.
the class InputArtifactsModifier method process.
@Override
public void process(Topology topology, FlowExecutionContext context) {
ApplicationEnvironment environment = context.getEnvironmentContext().orElseThrow(() -> new IllegalArgumentException("Input modifier requires an environment context.")).getEnvironment();
DeploymentInputs deploymentInputs = context.getConfiguration(DeploymentInputs.class, InputsModifier.class.getSimpleName()).orElse(new DeploymentInputs(environment.getTopologyVersion(), environment.getId()));
if (deploymentInputs.getInputArtifacts() == null) {
deploymentInputs.setInputArtifacts(Maps.newHashMap());
}
boolean updated = false;
// Cleanup inputs artifacts that does not exists anymore
Iterator<Entry<String, DeploymentArtifact>> inputArtifactsIterator = safe(deploymentInputs.getInputArtifacts()).entrySet().iterator();
while (inputArtifactsIterator.hasNext()) {
Entry<String, DeploymentArtifact> inputArtifactEntry = inputArtifactsIterator.next();
if (!topology.getInputArtifacts().containsKey(inputArtifactEntry.getKey())) {
inputArtifactsIterator.remove();
updated = true;
}
}
processInputArtifacts(topology, deploymentInputs.getInputArtifacts());
// should save if deploymentInput updated
if (updated) {
context.saveConfiguration(deploymentInputs);
}
}
Aggregations