Search in sources :

Example 1 with SetMatchedNodeModifier

use of org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedNodeModifier in project alien4cloud by alien4cloud.

the class NodeMatchingSubstitutionService method getModifierListWithSelectionAction.

private List<ITopologyModifier> getModifierListWithSelectionAction(SetMatchedNodeModifier matchedNodeModifier) {
    List<ITopologyModifier> modifierList = flowExecutor.getDefaultFlowModifiers();
    NodeMatchingCompositeModifier nodeMatchingModifier = (NodeMatchingCompositeModifier) modifierList.stream().filter(modifier -> modifier instanceof NodeMatchingCompositeModifier).findFirst().orElseThrow(() -> new IllegalArgumentException("Unexpected exception in deployment flow to update node substitution; unable to find the master node matching modifier to inject selection action modifier."));
    // inject the SetMatchedNodeModifier into the nodeMatchingModifiers, just after nodeMatchingConfigAutoSelectModifier
    nodeMatchingModifier.addModifierAfter(matchedNodeModifier, nodeMatchingConfigAutoSelectModifier);
    return modifierList;
}
Also used : TopologyServiceCore(alien4cloud.topology.TopologyServiceCore) AlienUtils.safe(alien4cloud.utils.AlienUtils.safe) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Map(java.util.Map) Application(alien4cloud.model.application.Application) ApplicationService(alien4cloud.application.ApplicationService) OnDeploymentConfigCopyEvent(org.alien4cloud.alm.deployment.configuration.events.OnDeploymentConfigCopyEvent) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier) MapUtils(org.apache.commons.collections4.MapUtils) Order(org.springframework.core.annotation.Order) NodeMatchingConfigAutoSelectModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingConfigAutoSelectModifier) Csar(org.alien4cloud.tosca.model.Csar) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Set(java.util.Set) SetMatchedNodeModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedNodeModifier) EventListener(org.springframework.context.event.EventListener) AbstractDeploymentConfig(org.alien4cloud.alm.deployment.configuration.model.AbstractDeploymentConfig) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) NotFoundException(alien4cloud.exception.NotFoundException) List(java.util.List) EnvironmentContext(org.alien4cloud.alm.deployment.configuration.flow.EnvironmentContext) FlowExecutor(org.alien4cloud.alm.deployment.configuration.flow.FlowExecutor) AbstractComposedModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.AbstractComposedModifier) DeploymentMatchingConfiguration(org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration) FlowExecutionContext(org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext) NodeMatchingCompositeModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingCompositeModifier) Topology(org.alien4cloud.tosca.model.templates.Topology) ITopologyModifier(org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier) NodeMatchingCompositeModifier(org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingCompositeModifier)

Example 2 with SetMatchedNodeModifier

use of org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedNodeModifier 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)

Aggregations

NotFoundException (alien4cloud.exception.NotFoundException)2 EnvironmentContext (org.alien4cloud.alm.deployment.configuration.flow.EnvironmentContext)2 FlowExecutionContext (org.alien4cloud.alm.deployment.configuration.flow.FlowExecutionContext)2 ITopologyModifier (org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier)2 SetMatchedNodeModifier (org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedNodeModifier)2 ApplicationService (alien4cloud.application.ApplicationService)1 Application (alien4cloud.model.application.Application)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 TopologyServiceCore (alien4cloud.topology.TopologyServiceCore)1 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)1 Maps (com.google.common.collect.Maps)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 OnDeploymentConfigCopyEvent (org.alien4cloud.alm.deployment.configuration.events.OnDeploymentConfigCopyEvent)1 FlowExecutor (org.alien4cloud.alm.deployment.configuration.flow.FlowExecutor)1 AbstractComposedModifier (org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.AbstractComposedModifier)1 NodeMatchingCompositeModifier (org.alien4cloud.alm.deployment.configuration.flow.modifiers.matching.NodeMatchingCompositeModifier)1