use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier 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.ITopologyModifier 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.ITopologyModifier in project alien4cloud by alien4cloud.
the class PolicyMatchingReplaceModifier method process.
@Override
public void process(Topology topology, FlowExecutionContext context) {
super.process(topology, context);
for (PolicyTemplate policyTemplate : safe(topology.getPolicies()).values()) {
PolicyType policyType = ToscaContext.getOrFail(PolicyType.class, policyTemplate.getType());
String policyImplMeta = TagUtil.getTagValue(policyType.getTags(), "a4c_policy_impl");
if (policyImplMeta == null) {
context.log().warn("Matched policy {} for {} does not define an alien topology modifier implementation, it may not be taken in account.", policyTemplate.getType(), policyTemplate.getName());
continue;
}
String[] policyImpl = policyImplMeta.split(":");
if (policyImpl.length != 3) {
context.log().error("Matched policy {} for policy {} defines an invalid modifier implementation {}, format should be policy_plugin_id:policy_plugin_bean:injection_phase", policyTemplate.getType(), policyTemplate.getName(), policyImplMeta);
}
try {
ITopologyModifier modifier = pluginModifierRegistry.getPluginBean(policyImpl[0], policyImpl[1]);
List<ITopologyModifier> phaseModifiers = (List<ITopologyModifier>) context.getExecutionCache().computeIfAbsent(policyImpl[2], s -> Lists.<ITopologyModifier>newArrayList());
// No need to add a modifier more than once for a phase
if (!phaseModifiers.contains(modifier)) {
phaseModifiers.add(modifier);
}
} catch (MissingPluginException e) {
context.log().error("Implementation specified for policy type {} that refers to plugin bean {}, {} cannot be found.", policyTemplate.getType(), policyImpl[0], policyImpl[1]);
}
}
}
use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.
the class MatchedPolicyPropertiesConfigService method updateProperty.
/**
* 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 for which to configure property.
* @param propertyName The id of the property to set value.
* @param propertyValue the value of the property.
* @return The flow execution context.
*/
public FlowExecutionContext updateProperty(Application application, ApplicationEnvironment environment, Topology topology, String nodeId, String propertyName, Object propertyValue) {
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).
List<ITopologyModifier> modifierList = getModifierListWithSelectionAction(nodeId, propertyName, propertyValue);
flowExecutor.execute(topology, modifierList, executionContext);
return executionContext;
}
use of org.alien4cloud.alm.deployment.configuration.flow.ITopologyModifier in project alien4cloud by alien4cloud.
the class MatchedNodePropertiesConfigService method updateProperty.
/**
* 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 for which to configure property.
* @param optionalCapabilityName An optional capability name in case we want to update a property of the capability.
* @param propertyName The id of the property to set value.
* @param propertyValue the value of the property.
* @return The flow execution context.
*/
public FlowExecutionContext updateProperty(Application application, ApplicationEnvironment environment, Topology topology, String nodeId, Optional<String> optionalCapabilityName, String propertyName, Object propertyValue) {
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).
List<ITopologyModifier> modifierList = getModifierListWithSelectionAction(nodeId, optionalCapabilityName, propertyName, propertyValue);
flowExecutor.execute(topology, modifierList, executionContext);
return executionContext;
}
Aggregations