use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes in project netvirt by opendaylight.
the class NexthopManager method installGroupOnDpn.
private void installGroupOnDpn(long groupId, BigInteger dpnId, String groupName, List<BucketInfo> bucketsInfo, String nextHopKey, GroupTypes groupType) {
NodeRef nodeRef = FibUtil.buildNodeRef(dpnId);
Buckets buckets = FibUtil.buildBuckets(bucketsInfo);
GroupRef groupRef = new GroupRef(FibUtil.buildGroupInstanceIdentifier(groupId, dpnId));
AddGroupInput input = new AddGroupInputBuilder().setNode(nodeRef).setGroupId(new GroupId(groupId)).setBuckets(buckets).setGroupRef(groupRef).setGroupType(groupType).setGroupName(groupName).build();
Future<RpcResult<AddGroupOutput>> groupStats = salGroupService.addGroup(input);
RpcResult<AddGroupOutput> rpcResult = null;
try {
rpcResult = groupStats.get();
if (rpcResult != null && rpcResult.isSuccessful()) {
LOG.info("Group {} with key {} has been successfully installed directly on dpn {}.", groupId, nextHopKey, dpnId);
} else {
LOG.error("Unable to install group {} with key {} directly on dpn {} due to {}.", groupId, nextHopKey, dpnId, rpcResult != null ? rpcResult.getErrors() : null);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error while installing group {} directly on dpn {}", groupId, dpnId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes in project openflowplugin by opendaylight.
the class MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
* (with different group types and capabilities).
*/
@Test
public void testMultipartReplyGroupFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 08 00 01 00 00 00 00 " + // types
"00 00 00 00 " + // capabilities
"00 00 00 00 " + // max groups
"00 00 00 01 " + // max groups
"00 00 00 02 " + // max groups
"00 00 00 03 " + // max groups
"00 00 00 04 " + // actions bitmap (all actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), message.getCapabilities());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes 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()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes in project openflowplugin by opendaylight.
the class MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyGroupFeatures() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 08 00 01 00 00 00 00 " + // types
"00 00 00 0F " + // capabilities
"00 00 00 0F " + // max groups
"00 00 00 01 " + // max groups
"00 00 00 02 " + // max groups
"00 00 00 03 " + // max groups
"00 00 00 04 " + // actions bitmap (all actions included)
"0F FF 98 01 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes());
Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), message.getCapabilities());
Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue());
Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue());
Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue());
Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue());
Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1));
Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2));
Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes 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());
}
Aggregations