use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType 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.GroupType in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createTestGroup.
private GroupBuilder createTestGroup(String actionType, String groupType, String groupmod, String strId) {
// Sample data , committing to DataStore
GroupBuilder group = new GroupBuilder();
BucketBuilder bucket = new BucketBuilder();
bucket.setBucketId(new BucketId((long) 12));
bucket.setKey(new BucketKey(new BucketId((long) 12)));
if (groupType == null) {
groupType = "g1";
}
if (actionType == null) {
actionType = "a1";
}
switch(groupType) {
case "g1":
group.setGroupType(GroupTypes.GroupSelect);
break;
case "g2":
group.setGroupType(GroupTypes.GroupAll);
break;
case "g3":
group.setGroupType(GroupTypes.GroupIndirect);
break;
case "g4":
group.setGroupType(GroupTypes.GroupFf);
break;
default:
break;
}
switch(actionType) {
case "a1":
bucket.setAction(createPopVlanAction());
break;
case "a2":
bucket.setAction(createPushVlanAction());
break;
case "a3":
bucket.setAction(createPushMplsAction());
break;
case "a4":
bucket.setAction(createPopMplsAction());
break;
case "a5":
bucket.setAction(createPopPbbAction());
break;
case "a6":
case "a7":
bucket.setAction(createPushPbbAction());
break;
case "a8":
bucket.setAction(createCopyTtlInAction());
break;
case "a9":
bucket.setAction(createCopyTtlOutAction());
break;
case "a10":
bucket.setAction(createDecMplsTtlAction());
break;
case "a14":
bucket.setAction(createGroupAction());
break;
case "a29":
bucket.setAction(createNonAppyPushVlanAction());
break;
default:
break;
}
if ("add".equals(groupmod)) {
bucket.setWatchGroup((long) 14);
bucket.setWatchPort((long) 1234);
bucket.setWeight(50);
} else {
bucket.setWatchGroup((long) 13);
bucket.setWatchPort((long) 134);
bucket.setWeight(30);
}
long id = Long.parseLong(strId);
GroupKey key = new GroupKey(new GroupId(id));
group.setKey(key);
// group.setInstall(false);
group.setGroupId(new GroupId(id));
group.setGroupName(originalGroupName);
group.setBarrier(false);
BucketsBuilder value = new BucketsBuilder();
List<Bucket> value1 = new ArrayList<>();
value1.add(bucket.build());
value.setBucket(value1);
group.setBuckets(value.build());
return group;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType in project openflowplugin by opendaylight.
the class OpenflowpluginGroupTestCommandProvider method createTestGroup.
private GroupBuilder createTestGroup(String actionType, String groupType, String groupMod) {
// Sample data , committing to DataStore
GroupBuilder group = new GroupBuilder();
BucketBuilder bucket = new BucketBuilder();
bucket.setBucketId(new BucketId((long) 12));
bucket.setKey(new BucketKey(new BucketId((long) 12)));
if (groupType == null) {
groupType = "g1";
}
if (actionType == null) {
actionType = "a1";
}
switch(groupType) {
case "g1":
group.setGroupType(GroupTypes.GroupSelect);
break;
case "g2":
group.setGroupType(GroupTypes.GroupAll);
break;
case "g3":
group.setGroupType(GroupTypes.GroupIndirect);
break;
case "g4":
group.setGroupType(GroupTypes.GroupFf);
break;
default:
break;
}
switch(actionType) {
case "a1":
bucket.setAction(createPopVlanAction());
break;
case "a2":
bucket.setAction(createPushVlanAction());
break;
case "a3":
bucket.setAction(createPushMplsAction());
break;
case "a4":
bucket.setAction(createPopMplsAction());
break;
case "a5":
bucket.setAction(createPopPbbAction());
break;
case "a6":
case "a7":
bucket.setAction(createPushPbbAction());
break;
case "a8":
bucket.setAction(createCopyTtlInAction());
break;
case "a9":
bucket.setAction(createCopyTtlOutAction());
break;
case "a10":
bucket.setAction(createDecMplsTtlAction());
break;
case "a11":
bucket.setAction(createDecNwTtlAction());
break;
case "a12":
bucket.setAction(createSetQueueAction());
break;
case "a13":
bucket.setAction(createSetNwTtlAction());
break;
case "a14":
bucket.setAction(createGroupAction());
break;
case "a15":
bucket.setAction(createSetMplsTtlAction());
break;
case "a16":
bucket.setAction(createFloodOutputAction());
break;
case "a17":
bucket.setAction(createAllOutputAction());
break;
case "a18":
bucket.setAction(createNormalOutputAction());
break;
case "a19":
bucket.setAction(creatTableOutputAction());
break;
case "a20":
bucket.setAction(createControllerAction());
break;
case "a21":
bucket.setAction(createLocalOutputAction());
break;
case "a22":
bucket.setAction(createAnyOutputAction());
break;
case "a23":
bucket.setAction(createInportOutputAction());
break;
case "a24":
bucket.setAction(null);
break;
case "a25":
bucket.setAction(createNonAppyOutputAction());
break;
case "a26":
bucket.setAction(createNonAppyPushMplsAction());
break;
case "a27":
bucket.setAction(createNonAppyPushPbbAction());
break;
case "a28":
bucket.setAction(createNonAppyPushVlanAction());
break;
default:
break;
}
if ("add".equals(groupMod)) {
bucket.setWatchGroup((long) 14);
bucket.setWatchPort((long) 1234);
bucket.setWeight(50);
} else {
bucket.setWatchGroup((long) 13);
bucket.setWatchPort((long) 134);
bucket.setWeight(30);
}
long id = 1;
GroupKey key = new GroupKey(new GroupId(id));
group.setKey(key);
// group.setInstall(false);
group.setGroupId(new GroupId(id));
group.setGroupName(ORIGINAL_GROUP_NAME);
group.setBarrier(false);
BucketsBuilder value = new BucketsBuilder();
List<Bucket> value1 = new ArrayList<>();
value1.add(bucket.build());
value.setBucket(value1);
group.setBuckets(value.build());
testGroup = group.build();
return group;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateGroupFeatures.
private static org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupFeatures translateGroupFeatures(final MultipartReply msg) {
final MultipartReplyGroupFeaturesBuilder message = new MultipartReplyGroupFeaturesBuilder();
final MultipartReplyGroupFeaturesCase caseBody = (MultipartReplyGroupFeaturesCase) msg.getMultipartReplyBody();
final MultipartReplyGroupFeatures replyBody = caseBody.getMultipartReplyGroupFeatures();
List<Class<? extends GroupType>> supportedGroups = new ArrayList<>();
if (replyBody.getTypes().isOFPGTALL()) {
supportedGroups.add(GroupAll.class);
}
if (replyBody.getTypes().isOFPGTSELECT()) {
supportedGroups.add(GroupSelect.class);
}
if (replyBody.getTypes().isOFPGTINDIRECT()) {
supportedGroups.add(GroupIndirect.class);
}
if (replyBody.getTypes().isOFPGTFF()) {
supportedGroups.add(GroupFf.class);
}
message.setGroupTypesSupported(supportedGroups);
message.setMaxGroups(replyBody.getMaxGroups());
List<Class<? extends GroupCapability>> supportedCapabilities = new ArrayList<>();
if (replyBody.getCapabilities().isOFPGFCCHAINING()) {
supportedCapabilities.add(Chaining.class);
}
if (replyBody.getCapabilities().isOFPGFCCHAININGCHECKS()) {
supportedCapabilities.add(ChainingChecks.class);
}
if (replyBody.getCapabilities().isOFPGFCSELECTLIVENESS()) {
supportedCapabilities.add(SelectLiveness.class);
}
if (replyBody.getCapabilities().isOFPGFCSELECTWEIGHT()) {
supportedCapabilities.add(SelectWeight.class);
}
message.setGroupCapabilitiesSupported(supportedCapabilities);
message.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupDescBody03.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
* Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL.
*/
@Test
public void testMultipartReplyGroupDescBody03() {
ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 " + // len
"00 48 " + // type
"01 " + // pad
"00 " + // groupId
"00 00 00 08 " + // bucketLen
"00 40 " + // bucketWeight
"00 06 " + // bucketWatchPort
"00 00 00 05 " + // bucketWatchGroup
"00 00 00 04 " + // bucketPad
"00 00 00 00 " + // popVlanType
"00 12 " + // popVlanLen
"00 08 " + // popVlanPad
"00 00 00 00 " + // popPbbType
"00 1B " + // popPbbLen
"00 08 " + // popPbbPad
"00 00 00 00 " + // popMplsType
"00 14 " + // popMplsLen
"00 08 " + // popMplsEthertype
"00 CF " + // popMplsPad
"00 00 " + // setQueueType
"00 15 " + // setQueueLen
"00 08 " + // setQueueQueueId
"00 CF 00 00 " + // groupType
"00 16 " + // groupLen
"00 08 " + // groupGroupId
"00 CF 00 00 " + // decNwTtlType
"00 18 " + // decNwTtlLen
"00 08 " + // decNwTtlPad
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
Assert.assertTrue("Wrong popVlanType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice() instanceof PopVlanCase);
Assert.assertTrue("Wrong popPbbType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice() instanceof PopPbbCase);
Assert.assertTrue("Wrong popMplsType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2).getActionChoice() instanceof PopMplsCase);
Assert.assertEquals("Wrong popMplsEthertype", 207, ((PopMplsCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2).getActionChoice()).getPopMplsAction().getEthertype().getValue().intValue());
Assert.assertTrue("Wrong setQueueType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3).getActionChoice() instanceof SetQueueCase);
Assert.assertEquals("Wrong setQueueQueueId", 13565952, ((SetQueueCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3).getActionChoice()).getSetQueueAction().getQueueId().intValue());
Assert.assertTrue("Wrong groupType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4).getActionChoice() instanceof GroupCase);
Assert.assertEquals("Wrong groupGroupId", 13565952, ((GroupCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4).getActionChoice()).getGroupAction().getGroupId().intValue());
Assert.assertTrue("Wrong decNwTtlType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5).getActionChoice() instanceof DecNwTtlCase);
}
Aggregations