use of alien4cloud.plugin.exception.MissingPluginException 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 alien4cloud.plugin.exception.MissingPluginException 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