Search in sources :

Example 6 with ITopologyModifier

use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.

the class NodeMatchingSubstitutionService method updateSubstitution.

/**
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 *
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param locationResourceTemplateId The id of the location resources to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application, ApplicationEnvironment environment, Topology topology, String nodeId, String locationResourceTemplateId) {
    FlowExecutionContext executionContext = new FlowExecutionContext(deploymentConfigurationDao, topology, new EnvironmentContext(application, environment));
    // Load the actual configuration
    // add a modifier that will actually perform the configuration of a substitution from user request (after cleanup and prior to node matching
    // auto-selection).
    SetMatchedNodeModifier setMatchedNodeModifier = new SetMatchedNodeModifier(nodeId, locationResourceTemplateId);
    List<ITopologyModifier> modifierList = getModifierListWithSelectionAction(setMatchedNodeModifier);
    flowExecutor.execute(topology, modifierList, executionContext);
    if (!setMatchedNodeModifier.isExecuted()) {
        throw new NotFoundException("Requested substitution <" + locationResourceTemplateId + "> for node <" + nodeId + "> is not available as a match. Please check that inputs and location are configured and ask your admin to grant you access to requested resources on the location.");
    }
    return executionContext;
}
Also used : EnvironmentContext(org.alien4cloud.alm.deployment.configuration.flow.EnvironmentContext) FlowExecutionContext(org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext) NotFoundException(alien4cloud.exception.NotFoundException) SetMatchedNodeModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedNodeModifier) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)

Example 7 with ITopologyModifier

use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.

the class PolicyMatchingSubstitutionService method updateSubstitution.

/**
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 *
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param resourceTemplateId The id of the location resource to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application, ApplicationEnvironment environment, Topology topology, String nodeId, String resourceTemplateId) {
    FlowExecutionContext executionContext = new FlowExecutionContext(deploymentConfigurationDao, topology, new EnvironmentContext(application, environment));
    // Load the actual configuration
    // add a modifier that will actually perform the configuration of a substitution from user request (after cleanup and prior to node matching
    // auto-selection).
    SetMatchedPolicyModifier setMatchedPolicyModifier = new SetMatchedPolicyModifier(nodeId, resourceTemplateId);
    List<ITopologyModifier> modifierList = getModifierListWithSelectionAction(setMatchedPolicyModifier);
    flowExecutor.execute(topology, modifierList, executionContext);
    if (!setMatchedPolicyModifier.isExecuted()) {
        throw new NotFoundException("Requested substitution <" + resourceTemplateId + "> for node <" + nodeId + "> is not available as a match. Please check that inputs and location are configured and ask your admin to grant you access to requested resources on the location.");
    }
    return executionContext;
}
Also used : EnvironmentContext(org.alien4cloud.alm.deployment.configuration.flow.EnvironmentContext) SetMatchedPolicyModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedPolicyModifier) FlowExecutionContext(org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext) NotFoundException(alien4cloud.exception.NotFoundException) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)

Example 8 with ITopologyModifier

use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.

the class FlowPhaseModifiersExecutor method process.

@Override
public void process(Topology topology, FlowExecutionContext context) {
    List<ITopologyModifier> phaseModifiers = (List<ITopologyModifier>) context.getExecutionCache().get(phase);
    if (phaseModifiers == null || phaseModifiers.isEmpty()) {
        log.debug("No topology modifiers found for phase {}", phase);
        return;
    }
    long start = System.currentTimeMillis();
    log.debug("Starting phase {} with {} modifiers to execute.", phase, phaseModifiers.size());
    for (ITopologyModifier modifier : phaseModifiers) {
        modifier.process(context.getTopology(), context);
        if (!context.log().isValid()) {
            // In case of errors we don't process the flow further.
            return;
        }
    }
    log.debug("Phase {} completed in {} ms.", phase, System.currentTimeMillis() - start);
}
Also used : List(java.util.List) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)

Example 9 with ITopologyModifier

use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.

the class LocationMatchingModifier method injectLocationTopologyModfier.

private void injectLocationTopologyModfier(FlowExecutionContext context, String locationName, LocationModifierReference modifierReference) {
    try {
        ITopologyModifier modifier = pluginModifierRegistry.getPluginBean(modifierReference.getPluginId(), modifierReference.getBeanName());
        List<ITopologyModifier> phaseModifiers = (List<ITopologyModifier>) context.getExecutionCache().get(modifierReference.getPhase());
        if (phaseModifiers == null) {
            phaseModifiers = Lists.newArrayList();
            context.getExecutionCache().put(modifierReference.getPhase(), phaseModifiers);
        }
        phaseModifiers.add(modifier);
    } catch (MissingPluginException e) {
        context.log().error("Location {} defines modifier that refers to plugin bean {}, {} cannot be found.", locationName, modifierReference.getPluginId(), modifierReference.getBeanName());
    }
}
Also used : MissingPluginException(alien4cloud.plugin.exception.MissingPluginException) LinkedList(java.util.LinkedList) List(java.util.List) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)

Aggregations

ITopologyModifier (org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)9 FlowExecutionContext (org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext)7 EnvironmentContext (org.alien4cloud.alm.deployment.configuration.flow.EnvironmentContext)6 List (java.util.List)5 NotFoundException (alien4cloud.exception.NotFoundException)4 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)3 Map (java.util.Map)3 Set (java.util.Set)3 Inject (javax.inject.Inject)3 DeploymentMatchingConfiguration (org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration)3 Topology (org.alien4cloud.tosca.model.templates.Topology)3 ApplicationService (alien4cloud.application.ApplicationService)2 Application (alien4cloud.model.application.Application)2 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)2 MissingPluginException (alien4cloud.plugin.exception.MissingPluginException)2 TopologyServiceCore (alien4cloud.topology.TopologyServiceCore)2 Maps (com.google.common.collect.Maps)2 Collectors (java.util.stream.Collectors)2 OnDeploymentConfigCopyEvent (org.alien4cloud.alm.deployment.configuration.events.OnDeploymentConfigCopyEvent)2 FlowExecutor (org.alien4cloud.alm.deployment.configuration.flow.FlowExecutor)2