Search in sources :

Example 1 with GroupKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project genius by opendaylight.

the class GroupEntity method getGroupBuilder.

public GroupBuilder getGroupBuilder() {
    if (groupBuilder == null) {
        groupBuilder = new GroupBuilder();
        GroupId groupId = new GroupId(getGroupId());
        groupBuilder.setKey(new GroupKey(groupId));
        groupBuilder.setGroupId(groupId);
        groupBuilder.setGroupName(getGroupName());
        groupBuilder.setGroupType(getGroupType());
        groupBuilder.setBuckets(MDSALUtil.buildBuckets(getBucketInfoList()));
    }
    return groupBuilder;
}
Also used : GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 2 with GroupKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey 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;
}
Also used : BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 3 with GroupKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method deleteGroup.

private void deleteGroup(final CommandInterpreter ci, Group group, Group group1) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(group.getGroupId()));
    modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
    modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
    InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(group1.getGroupId()));
    modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
    modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void notUsed) {
            ci.println("Status of Group Data Loaded Transaction: success.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 4 with GroupKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey 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;
}
Also used : BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 5 with GroupKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.

the class OpenflowpluginStatsTestCommandProvider method _groupStats.

public void _groupStats(CommandInterpreter ci) {
    int groupCount = 0;
    int groupStatsCount = 0;
    NodeGroupStatistics data = null;
    List<Node> nodes = getNodes();
    for (Node node2 : nodes) {
        NodeKey nodeKey = node2.getKey();
        InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
        ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
        FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
        if (node != null) {
            if (node.getGroup() != null) {
                List<Group> groups = node.getGroup();
                for (Group group2 : groups) {
                    groupCount++;
                    GroupKey groupKey = group2.getKey();
                    InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
                    Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
                    if (group != null) {
                        data = group.getAugmentation(NodeGroupStatistics.class);
                        if (null != data) {
                            groupStatsCount++;
                        }
                    }
                }
            }
        }
    }
    if (groupCount == groupStatsCount) {
        LOG.debug("---------------------groupStats - Success-------------------------------");
    } else {
        LOG.debug("------------------------------groupStats - Failed--------------------------");
        LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
    }
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Aggregations

GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)18 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)13 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)13 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)10 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)9 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)8 Test (org.junit.Test)6 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)5 StaleGroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey)5 ArrayList (java.util.ArrayList)4 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 StaleGroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder)4 FRMTest (test.mock.util.FRMTest)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)3 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)3 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)3 SalGroupServiceMock (test.mock.util.SalGroupServiceMock)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2