use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder 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.openflow.protocol.rev130731.GroupModInputBuilder 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.openflow.protocol.rev130731.GroupModInputBuilder 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.openflow.protocol.rev130731.GroupModInputBuilder in project openflowplugin by opendaylight.
the class GroupModInputMessageFactoryTest method testGroupModInputWithNoBuckets.
/**
* Testing of {@link GroupModInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testGroupModInputWithNoBuckets() throws Exception {
GroupModInputBuilder builder = new GroupModInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setCommand(GroupModCommand.forValue(2));
builder.setType(GroupType.forValue(3));
builder.setGroupId(new GroupId(256L));
GroupModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
groupModFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());
out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);
Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt());
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertorwithallParameters.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorwithallParameters() {
final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupAll);
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<>();
int actionOrder = 0;
// Action1
final GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroup("005");
final GroupAction groupIdaction = groupActionBuilder.build();
final ActionBuilder actionsB = new ActionBuilder();
actionsB.setOrder(actionOrder++).setAction(new GroupActionCaseBuilder().setGroupAction(groupIdaction).build());
// Action2:
final GroupActionBuilder groupActionBuilder1 = new GroupActionBuilder();
groupActionBuilder1.setGroup("006");
final GroupAction groupIdaction1 = groupActionBuilder.build();
final ActionBuilder actionsB1 = new ActionBuilder();
actionsB1.setOrder(actionOrder++).setAction(new GroupActionCaseBuilder().setGroupAction(groupIdaction1).build());
actionsList.add(actionsB.build());
actionsList.add(actionsB1.build());
final BucketsBuilder bucketsB = new BucketsBuilder();
final BucketBuilder bucketB = new BucketBuilder();
bucketB.setWeight(10);
bucketB.setWatchPort(20L);
bucketB.setWatchGroup(22L);
bucketB.setAction(actionsList);
final Bucket bucket = bucketB.build();
// List of bucket
bucketList.add(bucket);
final BucketBuilder bucketB1 = new BucketBuilder();
bucketB1.setWeight(50);
bucketB1.setWatchPort(60L);
bucketB1.setWatchGroup(70L);
// Action1
final CopyTtlInBuilder copyTtlB = new CopyTtlInBuilder();
final CopyTtlIn copyTtl = copyTtlB.build();
final ActionBuilder actionsB2 = new ActionBuilder();
actionsB2.setOrder(actionOrder++).setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtl).build());
// Action2:
final SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
final SetMplsTtlAction setMAction = setMplsTtlActionBuilder.build();
final ActionBuilder actionsB3 = new ActionBuilder();
actionsB3.setOrder(actionOrder++).setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMAction).build());
actionsList1.add(actionsB2.build());
actionsList1.add(actionsB3.build());
bucketB1.setAction(actionsList);
// 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.OFPGTALL, outAddGroupInput.getType());
assertEquals(10L, (long) outAddGroupInput.getGroupId().getValue());
assertEquals(10, (int) outAddGroupInput.getBucketsList().get(0).getWeight());
assertEquals(20L, (long) outAddGroupInput.getBucketsList().get(0).getWatchPort().getValue());
assertEquals((Long) 22L, outAddGroupInput.getBucketsList().get(0).getWatchGroup());
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());
}
// TODO:setMplsTTL :OF layer doesnt have get();
}
assertEquals((Integer) 50, outAddGroupInput.getBucketsList().get(1).getWeight());
assertEquals((long) 60, (long) outAddGroupInput.getBucketsList().get(1).getWatchPort().getValue());
assertEquals((Long) 70L, outAddGroupInput.getBucketsList().get(1).getWatchGroup());
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());
}
// TODO:setMplsTTL :OF layer doesnt have get();
}
}
Aggregations