Search in sources :

Example 1 with MultipartRequestExperimenterCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder in project openflowplugin by opendaylight.

the class MultipartRequestInputFactory method makeDefaultMultiLayerBody.

private static MultipartRequestBody makeDefaultMultiLayerBody(@Nonnull final MultipartType type, final short version) {
    switch(type) {
        case OFPMPDESC:
            return new MultipartRequestDescCaseBuilder().build();
        case OFPMPFLOW:
            final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
            MultipartRequestFlowBuilder multipartRequestFlowBuilder = new MultipartRequestFlowBuilder();
            multipartRequestFlowBuilder.setTableId(OFConstants.OFPTT_ALL);
            multipartRequestFlowBuilder.setOutPort(OFConstants.OFPP_ANY);
            multipartRequestFlowBuilder.setOutGroup(OFConstants.OFPG_ANY);
            multipartRequestFlowBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
            multipartRequestFlowBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
            switch(version) {
                case OFConstants.OFP_VERSION_1_0:
                    MatchV10Builder matchV10Builder = MatchUtil.createEmptyV10Match();
                    multipartRequestFlowBuilder.setMatchV10(matchV10Builder.build());
                    break;
                case OFConstants.OFP_VERSION_1_3:
                    multipartRequestFlowBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
                    break;
                default:
                    throw new IllegalArgumentException("Unknown version " + version);
            }
            multipartRequestFlowCaseBuilder.setMultipartRequestFlow(multipartRequestFlowBuilder.build());
            return multipartRequestFlowCaseBuilder.build();
        case OFPMPAGGREGATE:
            return new MultipartRequestAggregateCaseBuilder().build();
        case OFPMPTABLE:
            return new MultipartRequestTableCaseBuilder().build();
        case OFPMPPORTSTATS:
            MultipartRequestPortStatsCaseBuilder multipartRequestPortStatsCaseBuilder = new MultipartRequestPortStatsCaseBuilder();
            MultipartRequestPortStatsBuilder multipartRequestPortStatsBuilder = new MultipartRequestPortStatsBuilder();
            multipartRequestPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
            multipartRequestPortStatsCaseBuilder.setMultipartRequestPortStats(multipartRequestPortStatsBuilder.build());
            return multipartRequestPortStatsCaseBuilder.build();
        case OFPMPQUEUE:
            MultipartRequestQueueCaseBuilder multipartRequestQueueCaseBuilder = new MultipartRequestQueueCaseBuilder();
            MultipartRequestQueueBuilder multipartRequestQueueBuilder = new MultipartRequestQueueBuilder();
            multipartRequestQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
            multipartRequestQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
            multipartRequestQueueCaseBuilder.setMultipartRequestQueue(multipartRequestQueueBuilder.build());
            return multipartRequestQueueCaseBuilder.build();
        case OFPMPGROUP:
            MultipartRequestGroupCaseBuilder multipartRequestGroupCaseBuilder = new MultipartRequestGroupCaseBuilder();
            MultipartRequestGroupBuilder multipartRequestGroupBuilder = new MultipartRequestGroupBuilder();
            GroupId groupId = new GroupId(OFConstants.OFPG_ALL);
            multipartRequestGroupBuilder.setGroupId(groupId);
            multipartRequestGroupCaseBuilder.setMultipartRequestGroup(multipartRequestGroupBuilder.build());
            return multipartRequestGroupCaseBuilder.build();
        case OFPMPGROUPDESC:
            return new MultipartRequestGroupDescCaseBuilder().build();
        case OFPMPGROUPFEATURES:
            return new MultipartRequestGroupFeaturesCaseBuilder().build();
        case OFPMPMETER:
            MultipartRequestMeterCaseBuilder multipartRequestMeterCaseBuilder = new MultipartRequestMeterCaseBuilder();
            MultipartRequestMeterBuilder multipartRequestMeterBuilder = new MultipartRequestMeterBuilder();
            MeterId meterId = new MeterId(OFConstants.OFPM_ALL);
            multipartRequestMeterBuilder.setMeterId(meterId);
            multipartRequestMeterCaseBuilder.setMultipartRequestMeter(multipartRequestMeterBuilder.build());
            return multipartRequestMeterCaseBuilder.build();
        case OFPMPMETERCONFIG:
            MultipartRequestMeterConfigCaseBuilder multipartRequestMeterConfigCaseBuilder = new MultipartRequestMeterConfigCaseBuilder();
            MultipartRequestMeterConfigBuilder multipartRequestMeterConfigBuilder = new MultipartRequestMeterConfigBuilder();
            MeterId configMeterId = new MeterId(OFConstants.OFPM_ALL);
            multipartRequestMeterConfigBuilder.setMeterId(configMeterId);
            multipartRequestMeterConfigCaseBuilder.setMultipartRequestMeterConfig(multipartRequestMeterConfigBuilder.build());
            return multipartRequestMeterConfigCaseBuilder.build();
        case OFPMPMETERFEATURES:
            return new MultipartRequestMeterFeaturesCaseBuilder().build();
        case OFPMPTABLEFEATURES:
            MultipartRequestTableFeaturesCaseBuilder tableFeaturesCaseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
            tableFeaturesCaseBuilder.setMultipartRequestTableFeatures(new MultipartRequestTableFeaturesBuilder().build());
            return tableFeaturesCaseBuilder.build();
        case OFPMPPORTDESC:
            return new MultipartRequestPortDescCaseBuilder().build();
        case OFPMPEXPERIMENTER:
            return new MultipartRequestExperimenterCaseBuilder().build();
        default:
            throw new IllegalArgumentException("Unknown MultipartType " + type);
    }
}
Also used : MultipartRequestPortStatsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder) MultipartRequestMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder) MultipartRequestMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder) MultipartRequestQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder) MultipartRequestPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MultipartRequestQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder) MultipartRequestFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder) MultipartRequestFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) MultipartRequestGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder) MultipartRequestAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder) MultipartRequestDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder) MultipartRequestMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder) MultipartRequestGroupDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) MultipartRequestGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder) MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MultipartRequestMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder) MultipartRequestMeterFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder) MultipartRequestGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) MultipartRequestPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder)

Example 2 with MultipartRequestExperimenterCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFactory method setExperimenter.

private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
    MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
    MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
    caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder)

Example 3 with MultipartRequestExperimenterCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder in project openflowplugin by opendaylight.

the class MultiLayerExperimenterMultipartService method buildRequest.

@Override
@SuppressWarnings("unchecked")
protected OfHeader buildRequest(Xid xid, SendExperimenterMpRequestInput input) throws ServiceException {
    final TypeVersionKey key = new TypeVersionKey<>(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
    final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter = getExtensionConverterProvider().getMessageConverter(key);
    if (Objects.isNull(messageConverter)) {
        throw new ServiceException(new ConverterNotFoundException(key.toString()));
    }
    try {
        return RequestInputUtils.createMultipartHeader(MultipartType.OFPMPEXPERIMENTER, xid.getValue(), getVersion()).setMultipartRequestBody(new MultipartRequestExperimenterCaseBuilder().setMultipartRequestExperimenter(new MultipartRequestExperimenterBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice())).build()).build()).build();
    } catch (final ConversionException e) {
        throw new ServiceException(e);
    }
}
Also used : TypeVersionKey(org.opendaylight.openflowplugin.extension.api.TypeVersionKey) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) ServiceException(org.opendaylight.openflowplugin.impl.services.util.ServiceException) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ConverterNotFoundException(org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)

Example 4 with MultipartRequestExperimenterCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder in project openflowplugin by opendaylight.

the class OF10StatsRequestExperimenterTest method testExperimenter.

/**
 * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
 */
@Test
public void testExperimenter() throws Exception {
    Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
    OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
    multipartFactory.injectSerializerRegistry(mockRegistry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPEXPERIMENTER);
    builder.setFlags(new MultipartRequestFlags(false));
    final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
    MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
    expBuilder.setExperimenter(new ExperimenterId(42L));
    expBuilder.setExpType(21L);
    expBuilder.setExperimenterDataOfChoice(vendorData);
    caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 16);
    Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) OF10StatsRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory) MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 5 with MultipartRequestExperimenterCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder in project openflowplugin by opendaylight.

the class MultipartRequestInputMessageFactory method setExperimenter.

private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
    MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
    MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
    caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder)

Aggregations

MultipartRequestExperimenterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder)6 MultipartRequestExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder)5 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)2 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)2 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)2 MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)1 OF10StatsRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory)1 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)1 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)1 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)1 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)1 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)1 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)1 MultipartRequestAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder)1