use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class ActionResponseConvertor method convert.
@Override
public List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convert(List<Action> source, ActionResponseConvertorData data) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> result = new ArrayList<>();
final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
// Iterate over Openflow actions, run them through tokenizer and then add them to list of converted actions
if (source != null) {
for (final Action action : source) {
final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedAction = PROCESSOR.process(action.getActionChoice(), data, getConvertorExecutor());
if (convertedAction.isPresent()) {
result.add(convertedAction.get());
} else {
/**
* TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
* - we might also need a way on how to identify exact type of augmentation to be
* used as match can be bound to multiple models
*/
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction = ActionExtensionHelper.processAlienAction(action, ofVersion, data.getActionPath());
if (processedAction != null) {
result.add(processedAction);
}
}
}
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension 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.grouping.Extension 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.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.
the class OpenFlow13ProviderTest method checkMatchNsp.
private void checkMatchNsp(Match match, long nsp) {
GeneralAugMatchNodesNodeTableFlow genAug = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
assertNotNull(genAug);
List<ExtensionList> extensions = genAug.getExtensionList();
for (ExtensionList extensionList : extensions) {
Extension extension = extensionList.getExtension();
NxAugMatchNodesNodeTableFlow nxAugMatch = extension.getAugmentation(NxAugMatchNodesNodeTableFlow.class);
if (nxAugMatch.getNxmNxNsp() != null) {
assertEquals(nxAugMatch.getNxmNxNsp().getValue().longValue(), nsp);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.
the class OpenFlow13ProviderTest method checkMatchEthNsh.
private void checkMatchEthNsh(Match match) {
GeneralAugMatchNodesNodeTableFlow genAug = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
assertNotNull(genAug);
List<ExtensionList> extensions = genAug.getExtensionList();
for (ExtensionList extensionList : extensions) {
Extension extension = extensionList.getExtension();
NxAugMatchNodesNodeTableFlow nxAugMatch = extension.getAugmentation(NxAugMatchNodesNodeTableFlow.class);
if (nxAugMatch.getNxmNxEncapEthType() != null) {
assertEquals(nxAugMatch.getNxmNxEncapEthType().getValue().intValue(), OpenFlow13Utils.ETHERTYPE_NSH);
}
}
}
Aggregations