Search in sources :

Example 1 with MultipartReplyGroupFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateGroupFeatures.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeatures translateGroupFeatures(final MultipartReply msg) {
    final MultipartReplyGroupFeaturesBuilder message = new MultipartReplyGroupFeaturesBuilder();
    final MultipartReplyGroupFeaturesCase caseBody = (MultipartReplyGroupFeaturesCase) msg.getMultipartReplyBody();
    final MultipartReplyGroupFeatures replyBody = caseBody.getMultipartReplyGroupFeatures();
    List<Class<? extends GroupType>> supportedGroups = new ArrayList<>();
    if (replyBody.getTypes().isOFPGTALL()) {
        supportedGroups.add(GroupAll.class);
    }
    if (replyBody.getTypes().isOFPGTSELECT()) {
        supportedGroups.add(GroupSelect.class);
    }
    if (replyBody.getTypes().isOFPGTINDIRECT()) {
        supportedGroups.add(GroupIndirect.class);
    }
    if (replyBody.getTypes().isOFPGTFF()) {
        supportedGroups.add(GroupFf.class);
    }
    message.setGroupTypesSupported(supportedGroups);
    message.setMaxGroups(replyBody.getMaxGroups());
    List<Class<? extends GroupCapability>> supportedCapabilities = new ArrayList<>();
    if (replyBody.getCapabilities().isOFPGFCCHAINING()) {
        supportedCapabilities.add(Chaining.class);
    }
    if (replyBody.getCapabilities().isOFPGFCCHAININGCHECKS()) {
        supportedCapabilities.add(ChainingChecks.class);
    }
    if (replyBody.getCapabilities().isOFPGFCSELECTLIVENESS()) {
        supportedCapabilities.add(SelectLiveness.class);
    }
    if (replyBody.getCapabilities().isOFPGFCSELECTWEIGHT()) {
        supportedCapabilities.add(SelectWeight.class);
    }
    message.setGroupCapabilitiesSupported(supportedCapabilities);
    message.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
    return message.build();
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ArrayList(java.util.ArrayList) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder) GroupCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupCapability)

Example 2 with MultipartReplyGroupFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.

@Test
public void testGroupFeaturesSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(8));
    final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
    MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
    feature.setTypes(new GroupTypes(true, false, true, false));
    feature.setCapabilities(new GroupCapabilities(true, false, true, true));
    List<Long> maxGroups = new ArrayList<>();
    maxGroups.add(1L);
    maxGroups.add(2L);
    maxGroups.add(3L);
    maxGroups.add(4L);
    feature.setMaxGroups(maxGroups);
    feature.setActionsBitmap(createActionType());
    featureCase.setMultipartReplyGroupFeatures(feature.build());
    builder.setMultipartReplyBody(featureCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
    MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Example 3 with MultipartReplyGroupFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setGroupFeatures.

private static MultipartReplyGroupFeaturesCase setGroupFeatures(final ByteBuf rawMessage) {
    final MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder();
    MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder();
    featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt()));
    featuresBuilder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt()));
    List<Long> maxGroupsList = new ArrayList<>();
    for (int i = 0; i < GROUP_TYPES; i++) {
        maxGroupsList.add(rawMessage.readUnsignedInt());
    }
    featuresBuilder.setMaxGroups(maxGroupsList);
    List<ActionType> actionBitmaps = new ArrayList<>();
    for (int i = 0; i < GROUP_TYPES; i++) {
        actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt()));
    }
    featuresBuilder.setActionsBitmap(actionBitmaps);
    caseBuilder.setMultipartReplyGroupFeatures(featuresBuilder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) ActionType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType) ArrayList(java.util.ArrayList) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder)

Example 4 with MultipartReplyGroupFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder in project openflowplugin by opendaylight.

the class OpendaylightGroupStatisticsServiceImplTest method testGetGroupFeatures.

@Test
public void testGetGroupFeatures() throws Exception {
    GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyGroupFeaturesCaseBuilder().setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder().setActionsBitmap(Collections.singletonList(new ActionType(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false))).setCapabilities(new GroupCapabilities(true, false, false, false)).setTypes(new GroupTypes(true, false, false, false)).setMaxGroups(Collections.singletonList(5L)).build()).build()).build())).build();
    final Future<RpcResult<GetGroupFeaturesOutput>> resultFuture = groupStatisticsService.getGroupFeatures(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetGroupFeaturesOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPGROUPFEATURES, requestInput.getValue().getType());
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GetGroupFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) ActionType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetGroupFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Example 5 with MultipartReplyGroupFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtilTest method translateGroupFeatures.

@Test
public void translateGroupFeatures() {
    final MultipartReply multipartReply = buildReply(MultipartType.OFPMPGROUPFEATURES, new MultipartReplyGroupFeaturesCaseBuilder().setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder().setTypes(new GroupTypes(true, false, false, false)).setCapabilities(new GroupCapabilities(false, true, true, false)).setActionsBitmap(Collections.singletonList(new ActionType(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false))).build()).build());
    dummyAssertReply(multipartReply);
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) ActionType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Aggregations

MultipartReplyGroupFeaturesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder)4 MultipartReplyGroupFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ActionType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType)3 GroupCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities)3 GroupTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes)3 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 MultipartReplyGroupFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase)2 MultipartReplyGroupFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures)2 ByteBuf (io.netty.buffer.ByteBuf)1 GetGroupFeaturesInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder)1 GetGroupFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput)1 MultipartReplyGroupFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesBuilder)1 GroupCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupCapability)1 GroupType (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1