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);
}
}
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);
}
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;
}
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());
}
}
}
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());
}
Aggregations