Search in sources :

Example 1 with ActionPath

use of org.opendaylight.openflowplugin.extension.api.path.ActionPath in project openflowplugin by opendaylight.

the class InstructionDeserializerInjector method injectDeserializers.

/**
 * Injects instruction deserializers into provided
 * {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}.
 *
 * @param provider OpenflowJava deserializer extension provider
 */
static void injectDeserializers(final DeserializerExtensionProvider provider) {
    // Inject new instruction deserializers here using injector created by createInjector method
    final Function<Byte, Function<ActionPath, Consumer<OFDeserializer<Instruction>>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
    injector.apply(InstructionConstants.GOTO_TABLE_TYPE).apply(null).accept(new GoToTableInstructionDeserializer());
    injector.apply(InstructionConstants.WRITE_METADATA_TYPE).apply(null).accept(new WriteMetadataInstructionDeserializer());
    injector.apply(InstructionConstants.CLEAR_ACTIONS_TYPE).apply(null).accept(new ClearActionsInstructionDeserializer());
    injector.apply(InstructionConstants.METER_TYPE).apply(null).accept(new MeterInstructionDeserializer());
    for (ActionPath path : ActionPath.values()) {
        injector.apply(InstructionConstants.WRITE_ACTIONS_TYPE).apply(path).accept(new WriteActionsInstructionDeserializer(path));
        injector.apply(InstructionConstants.APPLY_ACTIONS_TYPE).apply(path).accept(new ApplyActionsInstructionDeserializer(path));
    }
}
Also used : OFDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer) WriteMetadataInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.WriteMetadataInstructionDeserializer) Function(java.util.function.Function) MeterInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.MeterInstructionDeserializer) GoToTableInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.GoToTableInstructionDeserializer) ActionPath(org.opendaylight.openflowplugin.extension.api.path.ActionPath) WriteActionsInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.WriteActionsInstructionDeserializer) ClearActionsInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.ClearActionsInstructionDeserializer) ApplyActionsInstructionDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.ApplyActionsInstructionDeserializer)

Example 2 with ActionPath

use of org.opendaylight.openflowplugin.extension.api.path.ActionPath in project openflowplugin by opendaylight.

the class ActionExtensionHelper method processAlienAction.

/**
 * Processes an alien action.
 *
 * @param action openflow action
 * @param ofVersion openflow version
 * @param actionPath openflow action path
 * @return augmentation wrapper containing augmentation depending on matchPath
 */
public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processAlienAction(final Action action, final OpenflowVersion ofVersion, final ActionPath actionPath) {
    ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
    final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
    if (Objects.isNull(extensionConvertorProvider)) {
        return null;
    }
    if (action.getActionChoice() instanceof ExperimenterIdCase) {
        ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
        // TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
        ExperimenterActionSerializerKey key = new ExperimenterActionSerializerKey(ofVersion.getVersion(), actionCase.getExperimenter().getExperimenter().getValue(), actionCase.getExperimenter().getSubType());
        convertor = extensionConvertorProvider.getActionConverter(key);
    } else if (action.getActionChoice() != null) {
        ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
        convertor = extensionConvertorProvider.getActionConverter(key);
    }
    if (convertor != null) {
        alienAction = convertor.convert(action, actionPath);
    }
    return alienAction;
}
Also used : ExperimenterIdCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) ExtensionConverterProvider(org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider) ActionPath(org.opendaylight.openflowplugin.extension.api.path.ActionPath) ExperimenterActionSerializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey) ActionSerializerKey(org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey) ExperimenterActionSerializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey)

Aggregations

ActionPath (org.opendaylight.openflowplugin.extension.api.path.ActionPath)2 Function (java.util.function.Function)1 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)1 ActionSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey)1 ExperimenterActionSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey)1 ExtensionConverterProvider (org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider)1 ApplyActionsInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.ApplyActionsInstructionDeserializer)1 ClearActionsInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.ClearActionsInstructionDeserializer)1 GoToTableInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.GoToTableInstructionDeserializer)1 MeterInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.MeterInstructionDeserializer)1 WriteActionsInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.WriteActionsInstructionDeserializer)1 WriteMetadataInstructionDeserializer (org.opendaylight.openflowplugin.impl.protocol.deserialization.instruction.WriteMetadataInstructionDeserializer)1 ExperimenterIdCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)1