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