Search in sources :

Example 1 with ActionMultipath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath in project openflowplugin by opendaylight.

the class MultipathCodec method serialize.

@Override
public void serialize(final Action input, final ByteBuf outBuffer) {
    ActionMultipath action = (ActionMultipath) input.getActionChoice();
    serializeHeader(LENGTH, NXAST_MULTIPATH_SUBTYPE, outBuffer);
    outBuffer.writeShort(action.getNxActionMultipath().getFields().getIntValue());
    outBuffer.writeShort(action.getNxActionMultipath().getBasis().shortValue());
    outBuffer.writeZero(2);
    outBuffer.writeShort(action.getNxActionMultipath().getAlgorithm().getIntValue());
    outBuffer.writeShort(action.getNxActionMultipath().getMaxLink().shortValue());
    outBuffer.writeInt(action.getNxActionMultipath().getArg().intValue());
    outBuffer.writeZero(2);
    outBuffer.writeShort(action.getNxActionMultipath().getOfsNbits().shortValue());
    outBuffer.writeInt(action.getNxActionMultipath().getDst().intValue());
}
Also used : ActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath)

Example 2 with ActionMultipath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath in project openflowplugin by opendaylight.

the class MultipathCodecTest method deserializeTest.

@Test
public void deserializeTest() {
    createBuffer(buffer);
    action = multipathCodec.deserialize(buffer);
    ActionMultipath result = (ActionMultipath) action.getActionChoice();
    assertEquals(OfjNxHashFields.NXHASHFIELDSETHSRC, result.getNxActionMultipath().getFields());
    assertEquals(1, result.getNxActionMultipath().getBasis().intValue());
    assertEquals(OfjNxMpAlgorithm.NXMPALGMODULON, result.getNxActionMultipath().getAlgorithm());
    assertEquals(2, result.getNxActionMultipath().getMaxLink().shortValue());
    assertEquals(3, result.getNxActionMultipath().getArg().intValue());
    assertEquals(4, result.getNxActionMultipath().getOfsNbits().shortValue());
    assertEquals(5, result.getNxActionMultipath().getDst().intValue());
    assertEquals(0, buffer.readableBytes());
}
Also used : ActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath) Test(org.junit.Test)

Example 3 with ActionMultipath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath in project openflowplugin by opendaylight.

the class MultipathConvertorTest method setUp.

@Before
public void setUp() throws Exception {
    final NxMultipath nxMultipath = Mockito.mock(NxMultipath.class);
    when(bucketActionsCase.getNxMultipath()).thenReturn(nxMultipath);
    final Dst dst = Mockito.mock(Dst.class);
    when(dst.getStart()).thenReturn(1);
    when(dst.getEnd()).thenReturn(2);
    final DstNxNspCase dstNxNspCase = Mockito.mock(DstNxNspCase.class);
    when(dst.getDstChoice()).thenReturn(dstNxNspCase);
    when(nxMultipath.getFields()).thenReturn(OfjNxHashFields.NXHASHFIELDSETHSRC);
    when(nxMultipath.getBasis()).thenReturn(2);
    when(nxMultipath.getAlgorithm()).thenReturn(OfjNxMpAlgorithm.NXMPALGHASHTHRESHOLD);
    when(nxMultipath.getMaxLink()).thenReturn(2);
    when(nxMultipath.getArg()).thenReturn(2L);
    when(nxMultipath.getDst()).thenReturn(dst);
    final ActionMultipath actionMultipath = Mockito.mock(ActionMultipath.class);
    final NxActionMultipath nxActionMultipath = Mockito.mock(NxActionMultipath.class);
    when(nxActionMultipath.getDst()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong());
    when(nxActionMultipath.getBasis()).thenReturn(1);
    when(nxActionMultipath.getAlgorithm()).thenReturn(OfjNxMpAlgorithm.NXMPALGHRW);
    when(nxActionMultipath.getMaxLink()).thenReturn(2);
    when(nxActionMultipath.getArg()).thenReturn(2L);
    when(actionMultipath.getNxActionMultipath()).thenReturn(nxActionMultipath);
    when(action.getActionChoice()).thenReturn(actionMultipath);
    multipathConvertor = new MultipathConvertor();
}
Also used : NxActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath) Dst(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst) NxActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath) ActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath) DstNxNspCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase) NxMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipath) Before(org.junit.Before)

Example 4 with ActionMultipath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath in project openflowplugin by opendaylight.

the class MultipathConvertorTest method testConvert.

@Test
public void testConvert() throws Exception {
    final ActionMultipath actionMultipath = (ActionMultipath) multipathConvertor.convert(bucketActionsCase).getActionChoice();
    Assert.assertEquals(OfjNxHashFields.NXHASHFIELDSETHSRC, actionMultipath.getNxActionMultipath().getFields());
    Assert.assertEquals(Integer.valueOf(2), actionMultipath.getNxActionMultipath().getBasis());
    Assert.assertEquals(OfjNxMpAlgorithm.NXMPALGHASHTHRESHOLD, actionMultipath.getNxActionMultipath().getAlgorithm());
    Assert.assertEquals(Integer.valueOf(2), actionMultipath.getNxActionMultipath().getMaxLink());
    Assert.assertEquals(Long.valueOf(2L), actionMultipath.getNxActionMultipath().getArg());
}
Also used : NxActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath) ActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath) Test(org.junit.Test)

Example 5 with ActionMultipath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath in project openflowplugin by opendaylight.

the class MultipathConvertor method convert.

@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.resolveDstValue(action.getDst()));
    dstBuilder.setStart(resolveStart(action.getOfsNbits()));
    dstBuilder.setEnd(resolveEnd(action.getOfsNbits()));
    NxMultipathBuilder builder = new NxMultipathBuilder();
    builder.setBasis(action.getBasis());
    builder.setAlgorithm(action.getAlgorithm());
    builder.setMaxLink(action.getMaxLink());
    builder.setArg(action.getArg());
    builder.setDst(dstBuilder.build());
    return resolveAction(builder.build(), path);
}
Also used : NxActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath) DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.DstBuilder) NxActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath) ActionMultipath(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath) NxMultipathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipathBuilder)

Aggregations

ActionMultipath (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath)5 NxActionMultipath (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.multipath.grouping.NxActionMultipath)3 Test (org.junit.Test)2 Before (org.junit.Before)1 DstNxNspCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase)1 NxMultipath (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipath)1 NxMultipathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.NxMultipathBuilder)1 Dst (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst)1 DstBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.DstBuilder)1