Search in sources :

Example 11 with GroupActionCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder 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();
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) CopyTtlIn(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlIn) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase) CopyTtlInCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) CopyTtlInBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) GroupActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder) SetMplsTtlActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) Test(org.junit.Test)

Example 12 with GroupActionCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder in project openflowplugin by opendaylight.

the class ReconcileUtilTest method createGroupWithPreconditions.

private Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
    final List<Action> actionBag = new ArrayList<>();
    for (long groupIdPrecondition : requiredId) {
        final GroupAction groupAction = new GroupActionBuilder().setGroupId(groupIdPrecondition).build();
        final GroupActionCase groupActionCase = new GroupActionCaseBuilder().setGroupAction(groupAction).build();
        final Action action = new ActionBuilder().setAction(groupActionCase).build();
        actionBag.add(action);
    }
    final Bucket bucket = new BucketBuilder().setAction(actionBag).build();
    final Buckets buckets = new BucketsBuilder().setBucket(Collections.singletonList(bucket)).build();
    return new GroupBuilder().setGroupId(new GroupId(groupIdValue)).setBuckets(buckets).build();
}
Also used : GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) GroupActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)

Example 13 with GroupActionCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder in project openflowplugin by opendaylight.

the class DSInputFactory method createGroupWithPreconditions.

public static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
    final List<Action> actionBag = new ArrayList<>();
    for (long groupIdPrecondition : requiredId) {
        final GroupAction groupAction = new GroupActionBuilder().setGroupId(groupIdPrecondition).build();
        final GroupActionCase groupActionCase = new GroupActionCaseBuilder().setGroupAction(groupAction).build();
        final Action action = new ActionBuilder().setAction(groupActionCase).build();
        actionBag.add(action);
    }
    final Bucket bucket = new BucketBuilder().setAction(actionBag).build();
    final Buckets buckets = new BucketsBuilder().setBucket(Collections.singletonList(bucket)).build();
    return new GroupBuilder().setGroupId(new GroupId(groupIdValue)).setBuckets(buckets).build();
}
Also used : GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) GroupActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)

Example 14 with GroupActionCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder in project openflowplugin by opendaylight.

the class GroupActionSerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final long group = 10L;
    final Action action = new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().setGroupId(group).build()).build();
    assertAction(action, out -> assertEquals(out.readUnsignedInt(), group));
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action) GroupActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) Test(org.junit.Test)

Aggregations

GroupActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder)14 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)13 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)12 ArrayList (java.util.ArrayList)9 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)8 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)7 PopVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder)6 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)6 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)6 PopMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder)5 PopPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder)5 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder)5 SetMplsTtlActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder)5 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)4 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)4 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)4 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)4 ActionKey (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey)4 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)3 GroupAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction)3