use of alien4cloud.topology.task.LocationPolicyTask in project alien4cloud by alien4cloud.
the class AbstractSetMatchedPropertyModifier method process.
@Override
public void process(Topology topology, FlowExecutionContext context) {
Optional<DeploymentMatchingConfiguration> configurationOptional = context.getConfiguration(DeploymentMatchingConfiguration.class, NodeMatchingConfigAutoSelectModifier.class.getSimpleName());
if (!configurationOptional.isPresent()) {
// we should not end-up here as location matching should be processed first
context.log().error(new LocationPolicyTask());
return;
}
DeploymentMatchingConfiguration matchingConfiguration = configurationOptional.get();
Map<String, String> lastUserSubstitutions = getUserMatches(matchingConfiguration);
U template = getTemplates(topology).get(templateId);
if (template == null) {
throw new NotFoundException("Topology [" + topology.getId() + "] does not contains any " + getSubject() + " with id [" + templateId + "]");
}
String substitutionId = lastUserSubstitutions.get(templateId);
if (substitutionId == null) {
throw new NotFoundException("The " + getSubject() + " [" + templateId + "] from topology [" + topology.getId() + "] is not matched.");
}
Map<String, V> allAvailableResourceTemplates = getAvailableResourceTemplates(context);
V resourceTemplate = allAvailableResourceTemplates.get(substitutionId);
try {
setProperty(context, resourceTemplate, template, matchingConfiguration);
} catch (ConstraintValueDoNotMatchPropertyTypeException | ConstraintViolationException e) {
throw new ConstraintTechnicalException("Dispatching constraint violation.", e);
}
}
Aggregations