Search in sources :

Example 11 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method setupLeavesEtreeBroadcastGroups.

public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
    EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
    if (etreeInstance != null) {
        long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
        List<Bucket> listBucket = new ArrayList<>();
        int bucketId = 0;
        int actionKey = 0;
        List<Action> listAction = new ArrayList<>();
        listAction.add(new ActionGroup(ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag)).buildAction(++actionKey));
        listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
        List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, etreeLeafTag);
        listBucket.addAll(listBucketInfoRemote);
        long groupId = ElanUtils.getEtreeLeafRemoteBCGId(etreeLeafTag);
        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
        LOG.trace("Installing the remote BroadCast Group:{}", group);
        mdsalManager.syncInstallGroup(dpnId, group);
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ArrayList(java.util.ArrayList) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 12 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method setupStandardElanBroadcastGroups.

public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId) {
    List<Bucket> listBucket = new ArrayList<>();
    int bucketId = 0;
    int actionKey = 0;
    Long elanTag = elanInfo.getElanTag();
    List<Action> listAction = new ArrayList<>();
    listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
    listBucket.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
    bucketId++;
    List<Bucket> listBucketInfoRemote = getRemoteBCGroupBuckets(elanInfo, dpnInterfaces, dpnId, bucketId, elanTag);
    listBucket.addAll(listBucketInfoRemote);
    long groupId = ElanUtils.getElanRemoteBCGId(elanTag);
    Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
    LOG.trace("Installing the remote BroadCast Group:{}", group);
    mdsalManager.syncInstallGroup(dpnId, group);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ArrayList(java.util.ArrayList) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 13 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project openflowplugin by opendaylight.

the class Activator method createBuckets.

private static BucketsBuilder createBuckets() {
    List<Action> actionList = new ArrayList<>();
    actionList.add(new ActionBuilder().setOrder(0).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build()).build());
    BucketBuilder bucketBuilder = new BucketBuilder();
    bucketBuilder.setBucketId(new BucketId(12L));
    bucketBuilder.setAction(actionList);
    List<Bucket> bucketList = new ArrayList<>();
    bucketList.add(bucketBuilder.build());
    actionList = new ArrayList<>();
    SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
    setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix("10.0.1.0/32")).build()).build());
    actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
    setFieldCaseBuilder = new SetFieldCaseBuilder();
    setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.10.0/32")).build()).build());
    actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
    bucketBuilder = new BucketBuilder();
    bucketBuilder.setBucketId(new BucketId(13L));
    bucketBuilder.setAction(actionList);
    bucketList.add(bucketBuilder.build());
    BucketsBuilder bucketsBuilder = new BucketsBuilder();
    bucketsBuilder.setBucket(bucketList);
    return bucketsBuilder;
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) SetFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) PopVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)

Example 14 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project openflowplugin by opendaylight.

the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
    int actionOrder = 0;
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupFf);
    final List<Bucket> bucketList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<>();
    // Action1: 005
    actionsList.add(assembleActionBuilder("005", actionOrder++).build());
    // Action2: 006
    actionsList.add(assembleActionBuilder("006", actionOrder++).build());
    // .. and mr.Bond is not coming today
    final BucketsBuilder bucketsB = new BucketsBuilder();
    final BucketBuilder bucketB = new BucketBuilder();
    bucketB.setAction(actionsList);
    final Bucket bucket = bucketB.build();
    // List of bucket
    bucketList.add(bucket);
    final BucketBuilder bucketB1 = new BucketBuilder();
    // Action1
    actionsList1.add(assembleCopyTtlInBuilder(actionOrder++).build());
    // Action2:
    actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
    bucketB1.setAction(actionsList1);
    // second bucket
    final Bucket bucket1 = bucketB1.build();
    bucketList.add(bucket1);
    // List of bucket added to the Buckets
    bucketsB.setBucket(bucketList);
    final Buckets buckets = bucketsB.build();
    addGroupBuilder.setBuckets(buckets);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
    assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
    final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
    for (int outItem = 0; outItem < outActionList.size(); outItem++) {
        final Action action = outActionList.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
    final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
    for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
        final Action action = outActionList1.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase) Test(org.junit.Test)

Example 15 with Bucket

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket in project openflowplugin by opendaylight.

the class GroupStatsResponseConvertorTest method testSingleGroupStat.

/**
 * Test single GroupStat conversion.
 */
@Test
public void testSingleGroupStat() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)41 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)41 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)16 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)14 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)13 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)12 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)12 BigInteger (java.math.BigInteger)11 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)11 Test (org.junit.Test)10 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)8 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)8 BucketsList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)8 List (java.util.List)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 Buckets (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)4 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)4 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)4