use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets in project netvirt by opendaylight.
the class ElanInterfaceManager method setupLeavesLocalBroadcastGroups.
private void setupLeavesLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
if (etreeInstance != null) {
List<Bucket> listBucket = new ArrayList<>();
int bucketId = 0;
List<String> interfaces = new ArrayList<>();
if (newDpnInterface != null) {
interfaces = newDpnInterface.getInterfaces();
}
for (String ifName : interfaces) {
// In case if there is a InterfacePort in the cache which is not
// in
// operational state, skip processing it
InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
if (!isOperational(ifInfo)) {
continue;
}
if (!interfaceManager.isExternalInterface(ifName)) {
// only add root interfaces
bucketId = addInterfaceIfRootInterface(bucketId, ifName, listBucket, ifInfo);
}
}
if (listBucket.isEmpty()) {
// No Buckets
createDropBucket(listBucket);
}
long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
long groupId = ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag);
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
LOG.trace("installing the localBroadCast Group:{}", group);
mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets in project netvirt by opendaylight.
the class ElanGroupListener method update.
@Override
protected void update(InstanceIdentifier<Group> identifier, Group original, Group update) {
LOG.trace("received group updated {}", update.getKey().getGroupId());
final BigInteger dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
return;
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
if (allDevices == null || allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.getKey().getGroupId());
return;
}
int expectedElanFootprint = 0;
final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
if (elanInstance == null) {
LOG.trace("no elan instance is null {}", update.getKey().getGroupId());
return;
}
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName());
if (devices == null || devices.isEmpty()) {
LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
return;
}
boolean updateGroup = false;
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
if (dpns.size() > 0) {
expectedElanFootprint += dpns.size();
} else {
updateGroup = true;
}
expectedElanFootprint += devices.size();
if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
updateGroup = true;
} else {
LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
if (updateGroup) {
List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag());
// remove local bcgroup bucket
expectedElanFootprint--;
if (bucketList.size() != expectedElanFootprint) {
// no point in retrying if not able to meet expected foot print
return;
}
LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId);
return null;
});
} else {
LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets 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.group.Buckets 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 in project openflowplugin by opendaylight.
the class GroupDescStatsResponseConvertorTest method testGroupDescStats.
/**
* Test single GroupDescStats conversion.
*/
@Test
public void testGroupDescStats() {
// **********************************************
// First group desc
// **********************************************
GroupDescBuilder builder = new GroupDescBuilder();
builder.setType(GroupType.OFPGTFF);
builder.setGroupId(new GroupId(42L));
// Buckets for first group desc
BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
bucketsBuilder.setWeight(16);
bucketsBuilder.setWatchPort(new PortNumber(84L));
bucketsBuilder.setWatchGroup(168L);
// Actions for buckets for first group desc
List<Action> actions = new ArrayList<>();
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
actions.add(actionBuilder.build());
// Build bucket with actions
bucketsBuilder.setAction(actions);
List<BucketsList> bucketsList = new ArrayList<>();
bucketsList.add(bucketsBuilder.build());
// Build first group desc
builder.setBucketsList(bucketsList);
List<GroupDesc> groupDescStats = new ArrayList<>();
groupDescStats.add(builder.build());
// **********************************************
// Second group desc
// **********************************************
builder = new GroupDescBuilder();
builder.setType(GroupType.OFPGTINDIRECT);
builder.setGroupId(new GroupId(50L));
// First buckets for second group desc
bucketsList = new ArrayList<>();
bucketsBuilder = new BucketsListBuilder();
bucketsBuilder.setWeight(100);
bucketsBuilder.setWatchPort(new PortNumber(200L));
bucketsBuilder.setWatchGroup(400L);
// Actions for first buckets for second group desc
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
// Build first bucket with actions
bucketsBuilder.setAction(actions);
bucketsList.add(bucketsBuilder.build());
// Second buckets for second group desc
bucketsBuilder = new BucketsListBuilder();
bucketsBuilder.setWeight(5);
bucketsBuilder.setWatchPort(new PortNumber(10L));
bucketsBuilder.setWatchGroup(15L);
// Actions for second buckets for second group desc
actions = new ArrayList<>();
// Build second bucket with actions
bucketsBuilder.setAction(actions);
bucketsList.add(bucketsBuilder.build());
// Build second group desc
builder.setBucketsList(bucketsList);
groupDescStats.add(builder.build());
VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
List<GroupDescStats> statsList = convert(groupDescStats, data);
Assert.assertEquals("Wrong groupDesc stats size", 2, statsList.size());
// **********************************************
// Test first group desc
// **********************************************
GroupDescStats stat = statsList.get(0);
Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType());
Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size());
// Test first bucket for first group desc
Bucket bucket = stat.getBuckets().getBucket().get(0);
Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 16, bucket.getWeight().intValue());
Assert.assertEquals("Wrong type", 168, bucket.getWatchGroup().intValue());
Assert.assertEquals("Wrong type", 84, bucket.getWatchPort().intValue());
Assert.assertEquals("Wrong type", 1, bucket.getAction().size());
// Test first action for first bucket for first group desc
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action = bucket.getAction().get(0);
Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.CopyTtlInCase", action.getAction().getImplementedInterface().getName());
// **********************************************
// Test second group desc
// **********************************************
stat = statsList.get(1);
Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType());
Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 50, stat.getKey().getGroupId().getValue().intValue());
Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size());
// Test first bucket for second group desc
bucket = stat.getBuckets().getBucket().get(0);
Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 100, bucket.getWeight().intValue());
Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue());
Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue());
Assert.assertEquals("Wrong type", 3, bucket.getAction().size());
// Test first action for first bucket of second group desc
action = bucket.getAction().get(0);
Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.CopyTtlOutCase", action.getAction().getImplementedInterface().getName());
// Test second action for first bucket of second group desc
action = bucket.getAction().get(1);
Assert.assertEquals("Wrong type", 1, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.DecNwTtlCase", action.getAction().getImplementedInterface().getName());
// Test third action for first bucket of second group desc
action = bucket.getAction().get(2);
Assert.assertEquals("Wrong type", 2, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.PopPbbActionCase", action.getAction().getImplementedInterface().getName());
// Test second bucket for second group desc
bucket = stat.getBuckets().getBucket().get(1);
Assert.assertEquals("Wrong type", 1, bucket.getKey().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 5, bucket.getWeight().intValue());
Assert.assertEquals("Wrong type", 15, bucket.getWatchGroup().intValue());
Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue());
Assert.assertEquals("Wrong type", 0, bucket.getAction().size());
}
Aggregations