Search in sources :

Example 1 with CtStateCaseValueBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder in project openflowplugin by opendaylight.

the class CtStateConvertorTest method testConvert1.

@Test
public void testConvert1() throws Exception {
    final CtStateValuesBuilder ctStateValuesBuilder = new CtStateValuesBuilder().setCtState(3L).setMask(4L);
    final CtStateCaseValueBuilder ctStateCaseValueBuilder = new CtStateCaseValueBuilder().setCtStateValues(ctStateValuesBuilder.build());
    final CtStateCaseValue ctStateCaseValue = ctStateCaseValueBuilder.build();
    when(matchEntry.getMatchEntryValue()).thenReturn(ctStateCaseValue);
    final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ctStateConvertor.convert(matchEntry, MatchPath.PACKET_RECEIVED_MATCH);
    Assert.assertEquals(3L, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
    Assert.assertEquals(4L, ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
    Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
    final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ctStateConvertor.convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH);
    Assert.assertEquals(3L, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
    Assert.assertEquals(4L, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
    Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
    final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ctStateConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
    Assert.assertEquals(3L, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
    Assert.assertEquals(4L, ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
    Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
    final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment3 = ctStateConvertor.convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH);
    Assert.assertEquals(3L, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
    Assert.assertEquals(4L, ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
    Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
}
Also used : CtStateValuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder) Extension(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension) CtStateCaseValue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValue) CtStateCaseValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder) Test(org.junit.Test)

Example 2 with CtStateCaseValueBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder in project openflowplugin by opendaylight.

the class CtStateConvertor method convert.

@Override
public MatchEntry convert(Extension extension) {
    Optional<NxmNxCtStateGrouping> matchGrouping = MatchUtil.CT_STATE_RESOLVER.getExtension(extension);
    if (!matchGrouping.isPresent()) {
        throw new CodecPreconditionException(extension);
    }
    CtStateCaseValueBuilder ctStateCaseValueBuilder = new CtStateCaseValueBuilder();
    CtStateValuesBuilder ctStateValuesBuilder = new CtStateValuesBuilder();
    ctStateValuesBuilder.setCtState(matchGrouping.get().getNxmNxCtState().getCtState());
    ctStateValuesBuilder.setMask(matchGrouping.get().getNxmNxCtState().getMask());
    ctStateCaseValueBuilder.setCtStateValues(ctStateValuesBuilder.build());
    MatchEntryBuilder ofMatch = MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtState.class, Nxm1Class.class, ctStateCaseValueBuilder.build());
    ofMatch.setHasMask(true);
    return ofMatch.build();
}
Also used : CtStateValuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) CtStateCaseValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder) NxmNxCtStateGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxCtStateGrouping) CodecPreconditionException(org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException)

Example 3 with CtStateCaseValueBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder in project openflowplugin by opendaylight.

the class CtStateCodecTest method createMatchEntry.

private MatchEntry createMatchEntry() {
    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
    final CtStateCaseValueBuilder caseBuilder = new CtStateCaseValueBuilder();
    final CtStateValuesBuilder valuesBuilder = new CtStateValuesBuilder();
    matchEntryBuilder.setOxmClass(Nxm1Class.class);
    matchEntryBuilder.setOxmMatchField(NxmNxCtState.class);
    matchEntryBuilder.setHasMask(true);
    valuesBuilder.setCtState((long) 1);
    valuesBuilder.setMask((long) 2);
    caseBuilder.setCtStateValues(valuesBuilder.build());
    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
    return matchEntryBuilder.build();
}
Also used : CtStateValuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) CtStateCaseValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder)

Example 4 with CtStateCaseValueBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder in project openflowplugin by opendaylight.

the class CtStateCodec method deserialize.

@Override
public MatchEntry deserialize(ByteBuf message) {
    final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
    CtStateCaseValueBuilder caseBuilder = new CtStateCaseValueBuilder();
    CtStateValuesBuilder ctStateValuesBuilder = new CtStateValuesBuilder();
    ctStateValuesBuilder.setCtState(message.readUnsignedInt());
    ctStateValuesBuilder.setMask(message.readUnsignedInt());
    caseBuilder.setCtStateValues(ctStateValuesBuilder.build());
    matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
    matchEntryBuilder.setHasMask(true);
    return matchEntryBuilder.build();
}
Also used : CtStateValuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) CtStateCaseValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder)

Aggregations

CtStateValuesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder)4 CtStateCaseValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder)4 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)3 Test (org.junit.Test)1 CodecPreconditionException (org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException)1 CtStateCaseValue (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValue)1 Extension (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension)1 NxmNxCtStateGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxCtStateGrouping)1