Search in sources :

Example 1 with AugmentTuple

use of org.opendaylight.openflowplugin.extension.api.AugmentTuple in project openflowplugin by opendaylight.

the class PacketReceivedTranslator method getPacketInMatch.

@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
    datapathIdConvertorData.setDatapathId(datapathId);
    final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
    final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
    final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
    if (matchExtensionWrap != null) {
        matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
    }
    return matchBuilder.build();
}
Also used : PacketInUtil(org.opendaylight.openflowplugin.impl.util.PacketInUtil) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) MatchPath(org.opendaylight.openflowplugin.extension.api.path.MatchPath) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MatchExtensionHelper(org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) Optional(java.util.Optional) BigInteger(java.math.BigInteger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) NodeConnectorRefToPortTranslator(org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with AugmentTuple

use of org.opendaylight.openflowplugin.extension.api.AugmentTuple in project openflowplugin by opendaylight.

the class MatchExtensionHelper method processAllExtensions.

/**
 * Processes all extensions.
 *
 * @param matchEntries match entries
 * @param ofVersion openflow version
 * @param matchPath match path
 * @param <E> extension point
 * @return augmentation wrapper containing augmentation depending on matchPath
 */
@SuppressWarnings("unchecked")
public static <E extends Augmentable<E>> AugmentTuple<E> processAllExtensions(Collection<MatchEntry> matchEntries, OpenflowVersion ofVersion, MatchPath matchPath) {
    List<ExtensionList> extensionsList = new ArrayList<>();
    for (MatchEntry matchEntry : matchEntries) {
        ExtensionListBuilder extensionListBld = processExtension(matchEntry, ofVersion.getVersion(), matchPath);
        if (extensionListBld == null) {
            continue;
        }
        extensionsList.add(extensionListBld.build());
    }
    AugmentTuple<E> augmentTuple = null;
    if (!extensionsList.isEmpty()) {
        switch(matchPath) {
            case FLOWS_STATISTICS_UPDATE_MATCH:
                GeneralAugMatchNotifUpdateFlowStatsBuilder generalExtMatchAugBld1 = new GeneralAugMatchNotifUpdateFlowStatsBuilder();
                generalExtMatchAugBld1.setExtensionList(extensionsList);
                augmentTuple = (AugmentTuple<E>) new AugmentTuple<>(GeneralAugMatchNotifUpdateFlowStats.class, generalExtMatchAugBld1.build());
                break;
            case PACKET_RECEIVED_MATCH:
                GeneralAugMatchNotifPacketInBuilder generalExtMatchAugBld2 = new GeneralAugMatchNotifPacketInBuilder();
                generalExtMatchAugBld2.setExtensionList(extensionsList);
                augmentTuple = (AugmentTuple<E>) new AugmentTuple<>(GeneralAugMatchNotifPacketIn.class, generalExtMatchAugBld2.build());
                break;
            case PACKET_IN_MESSAGE_MATCH:
                GeneralAugMatchPacketInMessageBuilder generalExtMatchAugBld5 = new GeneralAugMatchPacketInMessageBuilder();
                generalExtMatchAugBld5.setExtensionList(extensionsList);
                augmentTuple = (AugmentTuple<E>) new AugmentTuple<>(GeneralAugMatchPacketInMessage.class, generalExtMatchAugBld5.build());
                break;
            case SWITCH_FLOW_REMOVED_MATCH:
                GeneralAugMatchNotifSwitchFlowRemovedBuilder generalExtMatchAugBld3 = new GeneralAugMatchNotifSwitchFlowRemovedBuilder();
                generalExtMatchAugBld3.setExtensionList(extensionsList);
                augmentTuple = (AugmentTuple<E>) new AugmentTuple<>(GeneralAugMatchNotifSwitchFlowRemoved.class, generalExtMatchAugBld3.build());
                break;
            case FLOWS_STATISTICS_RPC_MATCH:
                GeneralAugMatchRpcOutputFlowStatsBuilder generalExtMatchAugBld4 = new GeneralAugMatchRpcOutputFlowStatsBuilder();
                generalExtMatchAugBld4.setExtensionList(extensionsList);
                augmentTuple = (AugmentTuple<E>) new AugmentTuple<>(GeneralAugMatchRpcOutputFlowStats.class, generalExtMatchAugBld4.build());
                break;
            default:
                LOG.warn("matchPath not supported: {}", matchPath);
        }
    }
    return augmentTuple;
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ExtensionListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder) GeneralAugMatchPacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchPacketInMessageBuilder) ArrayList(java.util.ArrayList) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) GeneralAugMatchNotifPacketInBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifPacketInBuilder) GeneralAugMatchRpcOutputFlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchRpcOutputFlowStatsBuilder) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList) GeneralAugMatchNotifSwitchFlowRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifSwitchFlowRemovedBuilder) GeneralAugMatchNotifUpdateFlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifUpdateFlowStatsBuilder)

Example 3 with AugmentTuple

use of org.opendaylight.openflowplugin.extension.api.AugmentTuple in project openflowplugin by opendaylight.

the class MatchExtensionHelperTest method testProcessAllExtensions.

@Test
public /**
 * Basic functionality test method for {@link MatchExtensionHelper#processAllExtensions(Collection,
 * OpenflowVersion, MatchPath)}.
 */
void testProcessAllExtensions() {
    List<MatchEntry> matchEntries = createMatchEntrieses();
    AugmentTuple augmentTuple = MatchExtensionHelper.processAllExtensions(matchEntries, OpenflowVersion.OF13, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
    assertNotNull(augmentTuple);
    augmentTuple = MatchExtensionHelper.processAllExtensions(matchEntries, OpenflowVersion.OF13, MatchPath.PACKET_RECEIVED_MATCH);
    assertNotNull(augmentTuple);
    augmentTuple = MatchExtensionHelper.processAllExtensions(matchEntries, OpenflowVersion.OF13, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
    assertNotNull(augmentTuple);
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) Test(org.junit.Test)

Aggregations

AugmentTuple (org.opendaylight.openflowplugin.extension.api.AugmentTuple)3 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 Test (org.junit.Test)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 MessageTranslator (org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator)1 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)1 MatchPath (org.opendaylight.openflowplugin.extension.api.path.MatchPath)1 NodeConnectorRefToPortTranslator (org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator)1 PacketInUtil (org.opendaylight.openflowplugin.impl.util.PacketInUtil)1 MatchExtensionHelper (org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper)1 ConvertorExecutor (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)1 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)1 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)1 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)1 PacketInMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage)1 GeneralAugMatchNotifPacketInBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNotifPacketInBuilder)1