use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder in project netvirt by opendaylight.
the class OpenFlow13Utils method addExtension.
private static void addExtension(MatchBuilder match, Class<? extends ExtensionKey> extensionKey, NxAugMatchNodesNodeTableFlow am) {
GeneralAugMatchNodesNodeTableFlow existingAugmentations = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
List<ExtensionList> extensions = null;
if (existingAugmentations != null) {
extensions = existingAugmentations.getExtensionList();
}
if (extensions == null) {
extensions = new ArrayList<>();
}
extensions.add(new ExtensionListBuilder().setExtensionKey(extensionKey).setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build()).build());
GeneralAugMatchNodesNodeTableFlow generalAugMatchNodesNode = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(extensions).build();
match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, generalAugMatchNodesNode);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder in project openflowplugin by opendaylight.
the class GroupingLooseResolverTest method testGetExtension.
@Test
public void testGetExtension() {
GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup = new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
eqGroup.add(GeneralAugMatchNodesNodeTableFlow.class);
eqGroup.add(GeneralAugMatchNotifPacketIn.class);
MatchBuilder mb1 = new MatchBuilder();
ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(JoachimTheBig.class).build();
GeneralAugMatchNodesNodeTableFlow odlxxx1 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension1)).build();
Match match1 = mb1.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx1).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder mb2 = new org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder();
ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(JoachimTheTiny.class).build();
GeneralAugMatchNotifPacketIn odlxxx2 = new GeneralAugMatchNotifPacketInBuilder().setExtensionList(Collections.singletonList(extension2)).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match match2 = mb2.addAugmentation(GeneralAugMatchNotifPacketIn.class, odlxxx2).build();
Assert.assertEquals(JoachimTheBig.class, eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
Assert.assertEquals(JoachimTheTiny.class, eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder in project openflowplugin by opendaylight.
the class GroupingResolverTest method testGetExtension.
/**
* test of method {@link GroupingResolver#getExtension(Augmentable)}.
*/
@Test
public void testGetExtension() {
GroupingResolver<GeneralExtensionListGrouping, Match> eqGroup = new GroupingResolver<>(GeneralExtensionListGrouping.class);
eqGroup.add(GeneralAugMatchNodesNodeTableFlow.class);
eqGroup.add(GeneralAugMatchRpcAddFlow.class);
MatchBuilder mb1 = new MatchBuilder();
ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(JoachimTheBig.class).build();
GeneralAugMatchNodesNodeTableFlow odlxxx1 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension1)).build();
Match match1 = mb1.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx1).build();
MatchBuilder mb2 = new MatchBuilder();
ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(JoachimTheTiny.class).build();
GeneralAugMatchNodesNodeTableFlow odlxxx2 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension2)).build();
Match match2 = mb2.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx2).build();
Assert.assertEquals(JoachimTheBig.class, eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
Assert.assertEquals(JoachimTheTiny.class, eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder in project openflowplugin by opendaylight.
the class MatchExtensionHelper method injectExtension.
/**
* Injects an extension.
*
* @param matchEntry match entry
* @param ofVersion openflow version
* @param matchPath match path
*/
public static void injectExtension(final short ofVersion, final MatchEntry matchEntry, final MatchBuilder matchBuilder, final MatchPath matchPath) {
final ExtensionListBuilder extBuilder = processExtension(matchEntry, ofVersion, matchPath);
if (Objects.isNull(extBuilder)) {
LOG.warn("Convertor for {} for version {} with match path {} not found.", matchEntry.toString(), ofVersion, matchPath.name());
}
final GeneralAugMatchNodesNodeTableFlowBuilder builder = Optional.ofNullable(matchBuilder.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class)).map(GeneralAugMatchNodesNodeTableFlowBuilder::new).orElse(new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(new ArrayList<>()));
builder.getExtensionList().add(extBuilder.build());
matchBuilder.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder 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;
}
Aggregations