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;
}
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;
}
Aggregations