import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.DstBuilder;
public class MultipathConvertor implements
- ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action>,
- ConvertorActionFromOFJava<Action, ActionPath> {
+ ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
+ Action>, ConvertorActionFromOFJava<Action, ActionPath> {
@Override
- public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(final Action input, final ActionPath path) {
+ public Action convert(
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
+ Preconditions.checkArgument(nxActionArg instanceof NxActionMultipathGrouping);
+ NxActionMultipathGrouping nxAction = (NxActionMultipathGrouping) nxActionArg;
+
+ NxActionMultipathBuilder nxActionMultipathBuilder = new NxActionMultipathBuilder();
+ nxActionMultipathBuilder.setFields(nxAction.getNxMultipath().getFields());
+ nxActionMultipathBuilder.setBasis(nxAction.getNxMultipath().getBasis());
+ nxActionMultipathBuilder.setAlgorithm(nxAction.getNxMultipath().getAlgorithm());
+ nxActionMultipathBuilder.setMaxLink(nxAction.getNxMultipath().getMaxLink());
+ nxActionMultipathBuilder.setArg(nxAction.getNxMultipath().getArg());
+ Dst dst = nxAction.getNxMultipath().getDst();
+ nxActionMultipathBuilder.setOfsNbits(dst.getStart() << 6 | dst.getEnd() - dst.getStart());
+ nxActionMultipathBuilder.setDst(RegMoveConvertor.resolveDst(dst.getDstChoice()));
+ ActionMultipathBuilder actionMultipathBuilder = new ActionMultipathBuilder();
+ actionMultipathBuilder.setNxActionMultipath(nxActionMultipathBuilder.build());
+ return ActionUtil.createAction(actionMultipathBuilder.build());
+ }
+
+ @Override
+ public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(
+ final Action input, final ActionPath path) {
NxActionMultipath action = ((ActionMultipath) input.getActionChoice()).getNxActionMultipath();
DstBuilder dstBuilder = new DstBuilder();
- dstBuilder.setDstChoice(RegMoveConvertor.resolveDst(action.getDst()));
+ dstBuilder.setDstChoice(RegMoveConvertor.resolveDstValue(action.getDst()));
dstBuilder.setStart(resolveStart(action.getOfsNbits()));
dstBuilder.setEnd(resolveEnd(action.getOfsNbits()));
NxMultipathBuilder builder = new NxMultipathBuilder();
private static int resolveEnd(final int ofsNBints) {
int ofs = extractSub(ofsNBints, 10, 6);
- int nBits = extractSub(ofsNBints, 6, 0);
- return ofs + nBits;
+ int numBits = extractSub(ofsNBints, 6, 0);
+ return ofs + numBits;
}
- private static int extractSub(final int l, final int nrBits, final int offset) {
- final int rightShifted = l >>> offset;
+ private static int extractSub(final int value, final int nrBits, final int offset) {
+ final int rightShifted = value >>> offset;
final int mask = (1 << nrBits) - 1;
return rightShifted & mask;
}
- private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(final NxMultipath value, final ActionPath path) {
+ private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action resolveAction(
+ final NxMultipath value, final ActionPath path) {
switch (path) {
- case NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION:
+ case INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS:
return new NxActionMultipathNodesNodeTableFlowWriteActionsCaseBuilder().setNxMultipath(value).build();
- case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
- return new NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCaseBuilder().setNxMultipath(value).build();
- case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
- return new NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCaseBuilder().setNxMultipath(value).build();
- case GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION:
+ case FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS:
+ return new NxActionMultipathNotifFlowsStatisticsUpdateWriteActionsCaseBuilder()
+ .setNxMultipath(value).build();
+ case FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS:
+ return new NxActionMultipathNotifFlowsStatisticsUpdateApplyActionsCaseBuilder()
+ .setNxMultipath(value).build();
+ case GROUP_DESC_STATS_UPDATED_BUCKET_ACTION:
return new NxActionMultipathNotifGroupDescStatsUpdatedCaseBuilder().setNxMultipath(value).build();
- case RPCFLOWSSTATISTICS_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION:
- return new NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCaseBuilder().setNxMultipath(value).build();
- case RPCFLOWSSTATISTICS_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION:
- return new NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCaseBuilder().setNxMultipath(value).build();
- case NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION:
+ case FLOWS_STATISTICS_RPC_WRITE_ACTIONS:
+ return new NxActionMultipathNotifDirectStatisticsUpdateWriteActionsCaseBuilder()
+ .setNxMultipath(value).build();
+ case FLOWS_STATISTICS_RPC_APPLY_ACTIONS:
+ return new NxActionMultipathNotifDirectStatisticsUpdateApplyActionsCaseBuilder()
+ .setNxMultipath(value).build();
+ case INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS:
return new NxActionMultipathNodesNodeTableFlowApplyActionsCaseBuilder().setNxMultipath(value).build();
default:
throw new CodecPreconditionException(path);
}
}
-
- @Override
- public Action convert(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
- Preconditions.checkArgument(nxActionArg instanceof NxActionMultipathGrouping);
- NxActionMultipathGrouping nxAction = (NxActionMultipathGrouping) nxActionArg;
-
- NxActionMultipathBuilder nxActionMultipathBuilder = new NxActionMultipathBuilder();
- nxActionMultipathBuilder.setFields(nxAction.getNxMultipath().getFields());
- nxActionMultipathBuilder.setBasis(nxAction.getNxMultipath().getBasis());
- nxActionMultipathBuilder.setAlgorithm(nxAction.getNxMultipath().getAlgorithm());
- nxActionMultipathBuilder.setMaxLink(nxAction.getNxMultipath().getMaxLink());
- nxActionMultipathBuilder.setArg(nxAction.getNxMultipath().getArg());
- Dst dst = nxAction.getNxMultipath().getDst();
- nxActionMultipathBuilder.setOfsNbits((dst.getStart() << 6) | (dst.getEnd() - dst.getStart()));
- nxActionMultipathBuilder.setDst(RegMoveConvertor.resolveDst(dst.getDstChoice()));
- ActionMultipathBuilder actionMultipathBuilder = new ActionMultipathBuilder();
- actionMultipathBuilder.setNxActionMultipath(nxActionMultipathBuilder.build());
- return ActionUtil.createAction(actionMultipathBuilder.build());
- }
-
}