use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder 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.service.rev130918.AddGroupInputBuilder 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.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertorNoBucket.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorNoBucket() {
final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupAll);
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.OFPGTALL, outAddGroupInput.getType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.
the class BundleAddMessageConverter method convertBundleGroupCase.
private BundleGroupModCase convertBundleGroupCase(final BundleInnerMessage messageCase, final VersionDatapathIdConvertorData data) throws ConversionException {
Optional<GroupModInputBuilder> groupModInput = Optional.empty();
final Class clazz = messageCase.getImplementedInterface();
if (clazz.equals(BundleAddGroupCase.class)) {
groupModInput = CONVERTER_EXECUTOR.convert(new AddGroupInputBuilder(((BundleAddGroupCase) messageCase).getAddGroupCaseData()).build(), data);
} else if (clazz.equals(BundleUpdateGroupCase.class)) {
groupModInput = CONVERTER_EXECUTOR.convert(new UpdatedGroupBuilder(((BundleUpdateGroupCase) messageCase).getUpdateGroupCaseData()).build(), data);
} else if (clazz.equals(BundleRemoveGroupCase.class)) {
groupModInput = CONVERTER_EXECUTOR.convert(new RemoveGroupInputBuilder(((BundleRemoveGroupCase) messageCase).getRemoveGroupCaseData()).build(), data);
}
if (groupModInput.isPresent()) {
return new BundleGroupModCaseBuilder().setGroupModCaseData(new GroupModCaseDataBuilder(groupModInput.get().setXid(xid).build()).build()).build();
} else {
throw new ConversionException("BundleGroupCase conversion unsuccessful.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.
the class SalGroupServiceImplTest method addGroup.
private void addGroup() {
final GroupId dummyGroupId = new GroupId(DUMMY_GROUP_ID);
AddGroupInput addGroupInput = new AddGroupInputBuilder().setGroupId(dummyGroupId).build();
this.<AddGroupOutput>mockSuccessfulFuture();
salGroupService.addGroup(addGroupInput);
verify(mockedRequestContextStack).createRequestContext();
}
Aggregations