Search in sources :

Example 1 with MultipartRequestInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFactory method deserialize.

@Override
public MultipartRequestInput deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    builder.setType(getMultipartType(type));
    builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort()));
    switch(getMultipartType(type)) {
        case OFPMPDESC:
            builder.setMultipartRequestBody(setDesc(rawMessage));
            break;
        case OFPMPFLOW:
            builder.setMultipartRequestBody(setFlow(rawMessage));
            break;
        case OFPMPAGGREGATE:
            builder.setMultipartRequestBody(setAggregate(rawMessage));
            break;
        case OFPMPTABLE:
            builder.setMultipartRequestBody(setTable(rawMessage));
            break;
        case OFPMPPORTSTATS:
            builder.setMultipartRequestBody(setPortStats(rawMessage));
            break;
        case OFPMPQUEUE:
            builder.setMultipartRequestBody(setQueue(rawMessage));
            break;
        case OFPMPEXPERIMENTER:
            builder.setMultipartRequestBody(setExperimenter(rawMessage));
            break;
        default:
            break;
    }
    return builder.build();
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)

Example 2 with MultipartRequestInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput in project openflowplugin by opendaylight.

the class PortStatsServiceTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    Xid xid = new Xid(42L);
    GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder().setNodeConnectorId(new NodeConnectorId("junitProto:11:12")).setNode(createNodeRef("junitProto:11"));
    final OfHeader request = portStatsService.buildRequest(xid, input.build());
    Assert.assertTrue(request instanceof MultipartRequestInput);
    final MultipartRequestInput mpRequest = (MultipartRequestInput) request;
    Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestPortStatsCase);
    final MultipartRequestPortStatsCase mpRequestBody = (MultipartRequestPortStatsCase) mpRequest.getMultipartRequestBody();
    Assert.assertEquals(12L, mpRequestBody.getMultipartRequestPortStats().getPortNo().longValue());
}
Also used : GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 3 with MultipartRequestInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput in project openflowplugin by opendaylight.

the class GroupDirectStatisticsServiceTest method testBuildRequestBody.

@Override
public void testBuildRequestBody() throws Exception {
    final GetGroupStatisticsInput input = mock(GetGroupStatisticsInput.class);
    when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
    when(input.getGroupId()).thenReturn(new GroupId(GROUP_NO));
    final MultipartRequestGroupCase body = (MultipartRequestGroupCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
    final MultipartRequestGroup group = body.getMultipartRequestGroup();
    assertEquals(GROUP_NO, group.getGroupId().getValue());
}
Also used : MultipartRequestGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroup) GetGroupStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 4 with MultipartRequestInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput in project openflowplugin by opendaylight.

the class NodeConnectorDirectStatisticsServiceTest method testBuildRequestBody.

@Override
public void testBuildRequestBody() throws Exception {
    final GetNodeConnectorStatisticsInput input = mock(GetNodeConnectorStatisticsInput.class);
    when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
    when(input.getNodeConnectorId()).thenReturn(nodeConnectorId);
    final MultipartRequestPortStatsCase body = (MultipartRequestPortStatsCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
    final MultipartRequestPortStats nodeConnector = body.getMultipartRequestPortStats();
    assertEquals(PORT_NO, nodeConnector.getPortNo());
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase) MultipartRequestPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput)

Example 5 with MultipartRequestInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput in project openflowplugin by opendaylight.

the class RequestInputUtilsTest method createMultipartHeader.

@Test
public void createMultipartHeader() throws Exception {
    final Short version = OFConstants.OFP_VERSION_1_3;
    final Long xid = 42L;
    final MultipartType type = MultipartType.OFPMPDESC;
    final MultipartRequestInput input = RequestInputUtils.createMultipartHeader(type, xid, version).build();
    assertEquals(version, input.getVersion());
    assertEquals(xid, input.getXid());
    assertEquals(type, input.getType());
    assertFalse(input.getFlags().isOFPMPFREQMORE());
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)59 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)59 ByteBuf (io.netty.buffer.ByteBuf)40 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)40 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)27 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)17 MultipartRequestBody (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody)8 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)7 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)3 MultipartRequestFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase)3 MultipartRequestPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase)3 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)2 MultipartRequestInputFactoryTest (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)2 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)2