use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class GroupUtil method extractGroupActionsSupportBitmap.
/*
* Method returns the bitmap of actions supported by each group.
*
* @param actionsSupported - list of supported actions
* @return
*/
public static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
List<Long> supportActionByGroups = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
long supportActionBitmap = 0;
supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? 1 : 0;
supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? 1 << 11 : 0;
supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? 1 << 12 : 0;
supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? 1 << 15 : 0;
supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? 1 << 16 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? 1 << 17 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? 1 << 18 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? 1 << 19 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? 1 << 20 : 0;
supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? 1 << 21 : 0;
supportActionBitmap |= supportedActions.isOFPATGROUP() ? 1 << 22 : 0;
supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? 1 << 23 : 0;
supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? 1 << 24 : 0;
supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? 1 << 25 : 0;
supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? 1 << 26 : 0;
supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? 1 << 27 : 0;
supportActionByGroups.add(supportActionBitmap);
}
return supportActionByGroups;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class GroupModInputMessageFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
// Test Message
Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
BucketsList bucket = deserializedMessage.getBucketsList().get(0);
Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group 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.Group in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method test.
@Test
public void test() throws Exception {
ByteBuf bb = BufferHelper.buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 " + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 " + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 " + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), deserializedMessage.getFlags());
Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch());
Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImpl method updateGroupsBatch.
@Override
public Future<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBatch(final UpdateGroupsBatchInput input) {
final List<BatchUpdateGroups> batchUpdateGroups = input.getBatchUpdateGroups();
LOG.trace("Updating groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), batchUpdateGroups.size());
final ArrayList<ListenableFuture<RpcResult<UpdateGroupOutput>>> resultsLot = new ArrayList<>();
for (BatchUpdateGroups batchGroup : batchUpdateGroups) {
final UpdateGroupInput updateGroupInput = new UpdateGroupInputBuilder(input).setOriginalGroup(new OriginalGroupBuilder(batchGroup.getOriginalBatchedGroup()).build()).setUpdatedGroup(new UpdatedGroupBuilder(batchGroup.getUpdatedBatchedGroup()).build()).setGroupRef(createGroupRef(input.getNode(), batchGroup)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.updateGroup(updateGroupInput)));
}
final Iterable<Group> groups = batchUpdateGroups.stream().map(BatchGroupInputUpdateGrouping::getUpdatedBatchedGroup).collect(Collectors.toList());
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), GroupUtil.<UpdateGroupOutput>createCumulatingFunction(groups, batchUpdateGroups.size()));
ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBulkFuture = Futures.transform(commonResult, GroupUtil.GROUP_UPDATE_TRANSFORM);
if (input.isBarrierAfter()) {
updateGroupsBulkFuture = BarrierUtil.chainBarrier(updateGroupsBulkFuture, input.getNode(), transactionService, GroupUtil.GROUP_UPDATE_COMPOSING_TRANSFORM);
}
return updateGroupsBulkFuture;
}
Aggregations