Search in sources :

Example 1 with CtActionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder in project openflowplugin by opendaylight.

the class ConntrackConvertor method getCtAction.

private List<CtActions> getCtAction(final NxActionConntrack action) {
    if (action.getCtActions() == null) {
        return null;
    }
    List<CtActions> ctActions = new ArrayList<>();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions ctAction : action.getCtActions()) {
        org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.OfpactActions ofpactAction = ctAction.getOfpactActions();
        if (ofpactAction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCase) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat nxActionNat = ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCase) ofpactAction).getNxActionNat();
            NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
            nxActionNatBuilder.setFlags(nxActionNat.getFlags());
            nxActionNatBuilder.setRangePresent(nxActionNat.getRangePresent());
            nxActionNatBuilder.setIpAddressMin(nxActionNat.getIpAddressMin());
            nxActionNatBuilder.setIpAddressMax(nxActionNat.getIpAddressMax());
            nxActionNatBuilder.setPortMin(nxActionNat.getPortMin());
            nxActionNatBuilder.setPortMax(nxActionNat.getPortMax());
            NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder();
            caseBuilder.setNxActionNat(nxActionNatBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActions.add(ctActionsBuilder.build());
        } else if (ofpactAction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCase) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMark nxActionCtMark = ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCase) ofpactAction).getNxActionCtMark();
            NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
            nxActionCtMarkBuilder.setCtMark(nxActionCtMark.getCtMark());
            // TODO: ct_mark mask is not supported yet
            NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder();
            caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActions.add(ctActionsBuilder.build());
        }
    }
    return ctActions;
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActions) ArrayList(java.util.ArrayList) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) NxActionCtMark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMark) NxActionNatCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCase) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder)

Example 2 with CtActionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder in project openflowplugin by opendaylight.

the class ConntrackCodecTest method createAction.

private Action createAction() {
    NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder();
    nxActionConntrackBuilder.setFlags(1);
    nxActionConntrackBuilder.setZoneSrc((long) 2);
    nxActionConntrackBuilder.setConntrackZone(3);
    nxActionConntrackBuilder.setRecircTable((short) 4);
    NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
    nxActionNatBuilder.setFlags(5);
    nxActionNatBuilder.setRangePresent(0x3F);
    nxActionNatBuilder.setIpAddressMin(new IpAddress("192.168.0.0".toCharArray()));
    nxActionNatBuilder.setIpAddressMax(new IpAddress("192.168.10.0".toCharArray()));
    nxActionNatBuilder.setPortMin(3000);
    nxActionNatBuilder.setPortMax(4000);
    NxActionNatCaseBuilder nxActionNatCaseBuilder = new NxActionNatCaseBuilder();
    nxActionNatCaseBuilder.setNxActionNat(nxActionNatBuilder.build());
    CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionNatCaseBuilder.build());
    List<CtActions> ctActionsList = new ArrayList<>();
    ctActionsList.add(ctActionsBuilder.build());
    nxActionNatBuilder = new NxActionNatBuilder();
    nxActionNatBuilder.setFlags(5);
    nxActionNatBuilder.setRangePresent(0x21);
    nxActionNatBuilder.setIpAddressMin(new IpAddress("192.168.0.0".toCharArray()));
    nxActionNatBuilder.setPortMax(4000);
    nxActionNatCaseBuilder = new NxActionNatCaseBuilder();
    nxActionNatCaseBuilder.setNxActionNat(nxActionNatBuilder.build());
    ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionNatCaseBuilder.build());
    ctActionsList.add(ctActionsBuilder.build());
    nxActionConntrackBuilder.setCtActions(ctActionsList);
    NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
    nxActionCtMarkBuilder.setCtMark((long) 36);
    NxActionCtMarkCaseBuilder nxActionCtMarkCaseBuilder = new NxActionCtMarkCaseBuilder();
    nxActionCtMarkCaseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
    ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionCtMarkCaseBuilder.build());
    ctActionsList.add(ctActionsBuilder.build());
    nxActionConntrackBuilder.setCtActions(ctActionsList);
    ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setExperimenterId(experimenterId);
    ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder();
    actionConntrackBuilder.setNxActionConntrack(nxActionConntrackBuilder.build());
    actionBuilder.setActionChoice(actionConntrackBuilder.build());
    return actionBuilder.build();
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) ArrayList(java.util.ArrayList) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 3 with CtActionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder in project openflowplugin by opendaylight.

the class ConntrackCodec method deserializeCtAction.

private void deserializeCtAction(final ByteBuf message, final NxActionConntrackBuilder nxActionConntrackBuilder, final int ctActionsLength) {
    List<CtActions> ctActionsList = new ArrayList<>();
    int processedCtActionsLength = ctActionsLength;
    while (processedCtActionsLength > 0) {
        int startReaderIndex = message.readerIndex();
        if (EncodeConstants.EXPERIMENTER_VALUE == message.readUnsignedShort()) {
            // NAT action
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            final int startIndex = message.readerIndex();
            int length = deserializeCtHeader(message);
            processedCtActionsLength = processedCtActionsLength - length;
            NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
            message.skipBytes(2);
            nxActionNatBuilder.setFlags(message.readUnsignedShort());
            int rangePresent = message.readUnsignedShort();
            nxActionNatBuilder.setRangePresent(rangePresent);
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMin(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MAX.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMax(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMIN.getIntValue())) {
                nxActionNatBuilder.setPortMin(message.readUnsignedShort());
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMAX.getIntValue())) {
                nxActionNatBuilder.setPortMax(message.readUnsignedShort());
            }
            NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder();
            caseBuilder.setNxActionNat(nxActionNatBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            int pad = length - (message.readerIndex() - startIndex);
            message.skipBytes(pad);
        } else {
            // only other possible action here is currently ct_mark
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            processedCtActionsLength = processedCtActionsLength - SET_FIELD_LENGTH;
            deserializeCtHeaderWithoutSubtype(message);
            NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
            nxActionCtMarkBuilder.setCtMark(message.readUnsignedInt());
            NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder();
            caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            // padding
            message.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
        }
    }
    nxActionConntrackBuilder.setCtActions(ctActionsList);
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) ArrayList(java.util.ArrayList) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder) InetAddress(java.net.InetAddress)

Example 4 with CtActionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder in project openflowplugin by opendaylight.

the class ConntrackConvertor method getCtAction.

private List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions> getCtAction(final NxConntrack action) {
    if (action.getCtActions() == null) {
        return null;
    }
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions> ctActions = new ArrayList<>();
    for (CtActions ctAction : action.getCtActions()) {
        OfpactActions ofpactAction = ctAction.getOfpactActions();
        if (ofpactAction instanceof NxActionNatCase) {
            NxActionNat nxActionNat = ((NxActionNatCase) ofpactAction).getNxActionNat();
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder nxActionNatBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder();
            nxActionNatBuilder.setFlags(nxActionNat.getFlags());
            nxActionNatBuilder.setRangePresent(nxActionNat.getRangePresent());
            nxActionNatBuilder.setIpAddressMin(nxActionNat.getIpAddressMin());
            nxActionNatBuilder.setIpAddressMax(nxActionNat.getIpAddressMax());
            nxActionNatBuilder.setPortMin(nxActionNat.getPortMin());
            nxActionNatBuilder.setPortMax(nxActionNat.getPortMax());
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder();
            caseBuilder.setNxActionNat(nxActionNatBuilder.build());
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder ctActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActions.add(ctActionsBuilder.build());
        } else if (ofpactAction instanceof NxActionCtMarkCase) {
            NxActionCtMark nxActionCtMark = ((NxActionCtMarkCase) ofpactAction).getNxActionCtMark();
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder nxActionCtMarkBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder();
            nxActionCtMarkBuilder.setCtMark(nxActionCtMark.getCtMark());
            // TODO: ct_mark mask is not supported yet
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder();
            caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder ctActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActions.add(ctActionsBuilder.build());
        }
    }
    return ctActions;
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActions) ArrayList(java.util.ArrayList) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder) NxActionNat(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) NxActionCtMark(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMark) NxActionCtMarkCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionCtMarkCase) NxActionNatCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCase) OfpactActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.OfpactActions) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder)

Example 5 with CtActionsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder in project openflowplugin by opendaylight.

the class ConntrackConvertorTest method testConvertFromOfJava.

@Test
public void testConvertFromOfJava() throws Exception {
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder nxActionNatBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder().setFlags(1).setRangePresent(2).setIpAddressMin(new IpAddress("192.168.0.0".toCharArray())).setIpAddressMax(new IpAddress("192.168.10.0".toCharArray())).setPortMin(3000).setPortMax(4000);
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder ctActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder().setOfpactActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder().setNxActionNat(nxActionNatBuilder.build()).build());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions> ctActions = new ArrayList<>();
    ctActions.add(ctActionsBuilder.build());
    final NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder().setConntrackZone(1).setFlags(1).setRecircTable((short) 1).setZoneSrc(1L).setCtActions(ctActions);
    final ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder().setNxActionConntrack(nxActionConntrackBuilder.build());
    final ActionBuilder actionBuilder = new ActionBuilder().setActionChoice(actionConntrackBuilder.build());
    final Action groupingAction = actionBuilder.build();
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = conntrackConvertor.convert(groupingAction, ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action1 = conntrackConvertor.convert(groupingAction, ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action2 = conntrackConvertor.convert(groupingAction, ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action3 = conntrackConvertor.convert(groupingAction, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action4 = conntrackConvertor.convert(groupingAction, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action5 = conntrackConvertor.convert(groupingAction, ActionPath.FLOWS_STATISTICS_RPC_APPLY_ACTIONS);
    Assert.assertEquals(1, ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getFlags().intValue());
    NxActionNat natActionCase = ((NxActionNatCase) ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getCtActions().get(0).getOfpactActions()).getNxActionNat();
    Assert.assertEquals(1, natActionCase.getFlags().shortValue());
    Assert.assertEquals(2, natActionCase.getRangePresent().intValue());
    Assert.assertEquals("192.168.0.0", natActionCase.getIpAddressMin().getIpv4Address().getValue());
    Assert.assertEquals("192.168.10.0", natActionCase.getIpAddressMax().getIpv4Address().getValue());
    Assert.assertEquals(3000, natActionCase.getPortMin().shortValue());
    Assert.assertEquals(4000, natActionCase.getPortMax().shortValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateWriteActionsCase) action1).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNotifFlowsStatisticsUpdateWriteActionsCase) action1).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateWriteActionsCase) action1).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateWriteActionsCase) action1).getNxConntrack().getFlags().intValue());
    NxActionNat natActionCase1 = ((NxActionNatCase) ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getCtActions().get(0).getOfpactActions()).getNxActionNat();
    Assert.assertEquals(1, natActionCase1.getFlags().shortValue());
    Assert.assertEquals(2, natActionCase1.getRangePresent().intValue());
    Assert.assertEquals("192.168.0.0", natActionCase1.getIpAddressMin().getIpv4Address().getValue());
    Assert.assertEquals("192.168.10.0", natActionCase1.getIpAddressMax().getIpv4Address().getValue());
    Assert.assertEquals(3000, natActionCase1.getPortMin().shortValue());
    Assert.assertEquals(4000, natActionCase1.getPortMax().shortValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateApplyActionsCase) action2).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNotifFlowsStatisticsUpdateApplyActionsCase) action2).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateApplyActionsCase) action2).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifFlowsStatisticsUpdateApplyActionsCase) action2).getNxConntrack().getFlags().intValue());
    NxActionNat natActionCase2 = ((NxActionNatCase) ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getCtActions().get(0).getOfpactActions()).getNxActionNat();
    Assert.assertEquals(1, natActionCase2.getFlags().shortValue());
    Assert.assertEquals(2, natActionCase2.getRangePresent().intValue());
    Assert.assertEquals("192.168.0.0", natActionCase2.getIpAddressMin().getIpv4Address().getValue());
    Assert.assertEquals("192.168.10.0", natActionCase2.getIpAddressMax().getIpv4Address().getValue());
    Assert.assertEquals(3000, natActionCase2.getPortMin().shortValue());
    Assert.assertEquals(4000, natActionCase2.getPortMax().shortValue());
    NxActionNat natActionCase3 = ((NxActionNatCase) ((NxActionConntrackNodesNodeTableFlowWriteActionsCase) action).getNxConntrack().getCtActions().get(0).getOfpactActions()).getNxActionNat();
    Assert.assertEquals(1, natActionCase3.getFlags().shortValue());
    Assert.assertEquals(2, natActionCase3.getRangePresent().intValue());
    Assert.assertEquals("192.168.0.0", natActionCase3.getIpAddressMin().getIpv4Address().getValue());
    Assert.assertEquals("192.168.10.0", natActionCase3.getIpAddressMax().getIpv4Address().getValue());
    Assert.assertEquals(3000, natActionCase3.getPortMin().shortValue());
    Assert.assertEquals(4000, natActionCase3.getPortMax().shortValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifGroupDescStatsUpdatedCase) action3).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNotifGroupDescStatsUpdatedCase) action3).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifGroupDescStatsUpdatedCase) action3).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifGroupDescStatsUpdatedCase) action3).getNxConntrack().getFlags().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateWriteActionsCase) action4).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNotifDirectStatisticsUpdateWriteActionsCase) action4).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateWriteActionsCase) action4).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateWriteActionsCase) action4).getNxConntrack().getFlags().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateApplyActionsCase) action5).getNxConntrack().getConntrackZone().longValue());
    Assert.assertEquals(1L, ((NxActionConntrackNotifDirectStatisticsUpdateApplyActionsCase) action5).getNxConntrack().getZoneSrc().longValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateApplyActionsCase) action5).getNxConntrack().getRecircTable().intValue());
    Assert.assertEquals(1, ((NxActionConntrackNotifDirectStatisticsUpdateApplyActionsCase) action5).getNxConntrack().getFlags().intValue());
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActions) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) ArrayList(java.util.ArrayList) NxActionNat(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat) NxActionConntrackNodesNodeTableFlowWriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionConntrackNodesNodeTableFlowWriteActionsCase) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) NxActionNatCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCase) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 CtActions (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActions)4 NxActionNatCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCase)4 NxActionNatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder)4 CtActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActionsBuilder)3 NxActionNatCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder)3 NxActionNat (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat)3 Test (org.junit.Test)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)2 ActionConntrackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder)2 NxActionConntrackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder)2 CtActions (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions)2 CtActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder)2 NxActionCtMarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder)2 NxActionNatCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder)2 NxActionCtMarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder)2 NxActionNatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder)2 NxActionConntrackNodesNodeTableFlowWriteActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionConntrackNodesNodeTableFlowWriteActionsCase)2 NxActionCtMarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder)2