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