use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping 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.GeneralExtensionListGrouping 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.GeneralExtensionListGrouping in project openflowplugin by opendaylight.
the class MatchConvertor method convert.
@Override
public List<MatchEntry> convert(final Match source, final VersionConvertorData data) {
List<MatchEntry> result = new ArrayList<>();
if (source == null) {
return result;
}
final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
inPortMatch(result, source.getInPort());
inPhyPortMatch(result, source.getInPhyPort());
metadataMatch(result, source.getMetadata());
ethernetMatch(result, source.getEthernetMatch());
vlanMatch(result, source.getVlanMatch());
ipMatch(result, source.getIpMatch());
layer4Match(result, source.getLayer4Match(), getConvertorExecutor(), extensionConvertorProvider);
icmpv4Match(result, source.getIcmpv4Match());
icmpv6Match(result, source.getIcmpv6Match());
layer3Match(result, source.getLayer3Match(), getConvertorExecutor(), extensionConvertorProvider);
protocolMatchFields(result, source.getProtocolMatchFields());
tunnelMatch(result, source.getTunnel());
tcpFlagsMatch(result, source.getTcpFlagsMatch());
/*
* TODO: EXTENSION PROPOSAL (source, MD-SAL to OFJava)
* - we might need version for conversion and for key
*/
Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(source);
if (extensionListOpt.isPresent()) {
List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
for (ExtensionList extensionItem : extensionListList) {
// TODO: get real version
ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
ConvertorToOFJava<MatchEntry> convertor = extensionConvertorProvider.getConverter(key);
if (convertor == null) {
throw new IllegalStateException("No converter found for key: " + key.toString());
}
MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
result.add(ofMatch);
}
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping in project openflowplugin by opendaylight.
the class SetFieldExtensionTest method testGetExtension.
@Test
public void testGetExtension() {
GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup = new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
eqGroup.add(GeneralAugMatchRpcAddFlowWriteActionsSetField.class);
eqGroup.add(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class);
SetFieldBuilder sb1 = new SetFieldBuilder();
ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(ZVendorExt1.class).build();
GeneralAugMatchRpcAddFlowWriteActionsSetField odlxxx1 = new GeneralAugMatchRpcAddFlowWriteActionsSetFieldBuilder().setExtensionList(Collections.singletonList(extension1)).build();
SetField setField1 = sb1.addAugmentation(GeneralAugMatchRpcAddFlowWriteActionsSetField.class, odlxxx1).build();
SetFieldBuilder sb2 = new SetFieldBuilder();
ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(ZVendorExt2.class).build();
GeneralAugMatchNodesNodeTableFlowWriteActionsSetField odlxxx2 = new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder().setExtensionList(Collections.singletonList(extension2)).build();
SetField setField2 = sb2.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class, odlxxx2).build();
Assert.assertEquals(ZVendorExt1.class, eqGroup.getExtension(setField1).get().getExtensionList().get(0).getExtensionKey());
Assert.assertEquals(ZVendorExt2.class, eqGroup.getExtension(setField2).get().getExtensionList().get(0).getExtensionKey());
}
Aggregations