Search in sources :

Example 11 with LocationPolicyTask

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);
    }
}
Also used : ConstraintValueDoNotMatchPropertyTypeException(org.alien4cloud.tosca.exceptions.ConstraintValueDoNotMatchPropertyTypeException) NotFoundException(alien4cloud.exception.NotFoundException) LocationPolicyTask(alien4cloud.topology.task.LocationPolicyTask) DeploymentMatchingConfiguration(org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration) ConstraintViolationException(org.alien4cloud.tosca.exceptions.ConstraintViolationException) ConstraintTechnicalException(org.alien4cloud.tosca.exceptions.ConstraintTechnicalException) NodeMatchingConfigAutoSelectModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingConfigAutoSelectModifier) NodePropsOverride(org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration.NodePropsOverride)

Aggregations

LocationPolicyTask (alien4cloud.topology.task.LocationPolicyTask)11 DeploymentMatchingConfiguration (org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration)10 Map (java.util.Map)5 List (java.util.List)4 Location (alien4cloud.model.orchestrators.locations.Location)3 NotFoundException (alien4cloud.exception.NotFoundException)2 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 NodeMatchingConfigAutoSelectModifier (org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingConfigAutoSelectModifier)2 NodePropsOverride (org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration.NodePropsOverride)2 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 NodeMatchingTask (alien4cloud.topology.task.NodeMatchingTask)1 UnavailableLocationTask (alien4cloud.topology.task.UnavailableLocationTask)1 OrchestratorDeploymentProperties (org.alien4cloud.alm.deployment.configuration.model.OrchestratorDeploymentProperties)1 ConstraintTechnicalException (org.alien4cloud.tosca.exceptions.ConstraintTechnicalException)1 ConstraintValueDoNotMatchPropertyTypeException (org.alien4cloud.tosca.exceptions.ConstraintValueDoNotMatchPropertyTypeException)1 ConstraintViolationException (org.alien4cloud.tosca.exceptions.ConstraintViolationException)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)1