use of org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedPolicyModifier in project alien4cloud by alien4cloud.
the class PolicyMatchingSubstitutionService method getModifierListWithSelectionAction.
private List<ITopologyModifier> getModifierListWithSelectionAction(SetMatchedPolicyModifier matchedModifier) {
List<ITopologyModifier> modifierList = flowExecutor.getDefaultFlowModifiers();
PolicyMatchingCompositeModifier matchingModifier = (PolicyMatchingCompositeModifier) modifierList.stream().filter(modifier -> modifier instanceof PolicyMatchingCompositeModifier).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 policyMatchingConfigAutoSelectModifier
matchingModifier.addModifierAfter(matchedModifier, policyMatchingConfigAutoSelectModifier);
return modifierList;
}
use of org.alien4cloud.alm.deployment.configuration.flow.modifiers.action.SetMatchedPolicyModifier 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;
}
Aggregations