Search in sources :

Example 91 with Group

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;
}
Also used : ActionType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType) ArrayList(java.util.ArrayList)

Example 92 with Group

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());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) GroupModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) Test(org.junit.Test)

Example 93 with Group

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());
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) 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) 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) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 94 with Group

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());
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) FlowModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) Test(org.junit.Test)

Example 95 with Group

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;
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) BatchFailedGroupsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput) ArrayList(java.util.ArrayList) OriginalGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder) UpdatedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) BatchUpdateGroups(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Aggregations

ArrayList (java.util.ArrayList)71 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)50 Test (org.junit.Test)45 BigInteger (java.math.BigInteger)35 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)31 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)20 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)18 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)18 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)17 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)15 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)14 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)13 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)13 ByteBuf (io.netty.buffer.ByteBuf)12 List (java.util.List)12 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)11 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)11