Search in sources :

Example 16 with DefaultGroupKey

use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testInitialAuditWithPendingGroupRequests.

// Test initial AUDIT process with pending group requests
private void testInitialAuditWithPendingGroupRequests(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
    }
    PortNumber[] ports1 = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    PortNumber[] ports2 = { PortNumber.portNumber(41), PortNumber.portNumber(42) };
    GroupId gId1 = new GroupId(1);
    Group group1 = createSouthboundGroupEntry(gId1, Arrays.asList(ports1), 0, deviceId);
    GroupId gId2 = new GroupId(2);
    // Non zero reference count will make the group manager to queue
    // the extraneous groups until reference count is zero.
    Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 2, deviceId);
    List<Group> groupEntries = Arrays.asList(group1, group2);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    // First group metrics would trigger the device audit completion
    // post which all pending group requests are also executed.
    GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
    Group createdGroup = groupManager.getGroup(deviceId, key);
    int createdGroupId = createdGroup.id().id();
    assertNotEquals(gId1.id().intValue(), createdGroupId);
    assertNotEquals(gId2.id().intValue(), createdGroupId);
    List<GroupOperation> expectedGroupOps = Arrays.asList(GroupOperation.createDeleteGroupOperation(gId1, Group.Type.SELECT), GroupOperation.createAddGroupOperation(createdGroup.id(), Group.Type.SELECT, createdGroup.buckets()));
    if (deviceId.equals(VDID1)) {
        provider.validate(networkId, deviceId, expectedGroupOps);
    }
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PortNumber(org.onosproject.net.PortNumber) GroupOperation(org.onosproject.net.group.GroupOperation) GroupId(org.onosproject.core.GroupId)

Example 17 with DefaultGroupKey

use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testRemoveGroup.

// Test group remove operations
private void testRemoveGroup(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    TestGroupListener listener;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
        listener = listener1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
        listener = listener2;
    }
    GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
    Group existingGroup = groupManager.getGroup(deviceId, currKey);
    groupManager.removeGroup(deviceId, currKey, appId);
    List<GroupOperation> expectedGroupOps = Collections.singletonList(GroupOperation.createDeleteGroupOperation(existingGroup.id(), Group.Type.SELECT));
    if (deviceId.equals(VDID1)) {
        provider.validate(networkId, deviceId, expectedGroupOps);
    }
    List<Group> groupEntries = Collections.emptyList();
    providerService.pushGroupMetrics(deviceId, groupEntries);
    listener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED));
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupOperation(org.onosproject.net.group.GroupOperation)

Example 18 with DefaultGroupKey

use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testAuditWithConfirmedGroups.

// Test AUDIT with confirmed groups
private void testAuditWithConfirmedGroups(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    TestGroupListener listener;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
        listener = listener1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
        listener = listener2;
    }
    GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
    Group createdGroup = groupManager.getGroup(deviceId, key);
    createdGroup = new DefaultGroup(createdGroup.id(), deviceId, Group.Type.SELECT, createdGroup.buckets());
    List<Group> groupEntries = Collections.singletonList(createdGroup);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    listener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADDED));
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroup(org.onosproject.net.group.DefaultGroup)

Example 19 with DefaultGroupKey

use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testAddBuckets.

// Test group add bucket operations
private void testAddBuckets(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    TestGroupListener listener;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
        listener = listener1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
        listener = listener2;
    }
    GroupKey addKey = new DefaultGroupKey("group1AddBuckets".getBytes());
    GroupKey prevKey = new DefaultGroupKey("group1BeforeAudit".getBytes());
    Group createdGroup = groupManager.getGroup(deviceId, prevKey);
    List<GroupBucket> buckets = new ArrayList<>();
    buckets.addAll(createdGroup.buckets().buckets());
    PortNumber[] addPorts = { PortNumber.portNumber(51), PortNumber.portNumber(52) };
    List<PortNumber> outPorts;
    outPorts = new ArrayList<>();
    outPorts.addAll(Arrays.asList(addPorts));
    List<GroupBucket> addBuckets;
    addBuckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        addBuckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupAddBuckets = new GroupBuckets(addBuckets);
    groupManager.addBucketsToGroup(deviceId, prevKey, groupAddBuckets, addKey, appId);
    GroupBuckets updatedBuckets = new GroupBuckets(buckets);
    List<GroupOperation> expectedGroupOps = Collections.singletonList(GroupOperation.createModifyGroupOperation(createdGroup.id(), Group.Type.SELECT, updatedBuckets));
    if (deviceId.equals(VDID1)) {
        provider.validate(networkId, deviceId, expectedGroupOps);
    }
    Group existingGroup = groupManager.getGroup(deviceId, addKey);
    List<Group> groupEntries = Collections.singletonList(existingGroup);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    listener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED));
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) PortNumber(org.onosproject.net.PortNumber) GroupOperation(org.onosproject.net.group.GroupOperation)

Example 20 with DefaultGroupKey

use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testRemoveBuckets.

// Test group remove bucket operations
private void testRemoveBuckets(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    TestGroupListener listener;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
        listener = listener1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
        listener = listener2;
    }
    GroupKey removeKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
    GroupKey prevKey = new DefaultGroupKey("group1AddBuckets".getBytes());
    Group createdGroup = groupManager.getGroup(deviceId, prevKey);
    List<GroupBucket> buckets = new ArrayList<>();
    buckets.addAll(createdGroup.buckets().buckets());
    PortNumber[] removePorts = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.addAll(Arrays.asList(removePorts));
    List<GroupBucket> removeBuckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        removeBuckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
        buckets.remove(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupRemoveBuckets = new GroupBuckets(removeBuckets);
    groupManager.removeBucketsFromGroup(deviceId, prevKey, groupRemoveBuckets, removeKey, appId);
    GroupBuckets updatedBuckets = new GroupBuckets(buckets);
    List<GroupOperation> expectedGroupOps = Collections.singletonList(GroupOperation.createModifyGroupOperation(createdGroup.id(), Group.Type.SELECT, updatedBuckets));
    if (deviceId.equals(VDID1)) {
        provider.validate(networkId, deviceId, expectedGroupOps);
    }
    Group existingGroup = groupManager.getGroup(deviceId, removeKey);
    List<Group> groupEntries = Collections.singletonList(existingGroup);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    listener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED));
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) PortNumber(org.onosproject.net.PortNumber) GroupOperation(org.onosproject.net.group.GroupOperation)

Aggregations

DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)52 GroupKey (org.onosproject.net.group.GroupKey)48 GroupBuckets (org.onosproject.net.group.GroupBuckets)39 GroupBucket (org.onosproject.net.group.GroupBucket)38 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)34 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)34 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)32 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)31 GroupDescription (org.onosproject.net.group.GroupDescription)27 Group (org.onosproject.net.group.Group)21 GroupId (org.onosproject.core.GroupId)19 PortNumber (org.onosproject.net.PortNumber)18 DefaultGroup (org.onosproject.net.group.DefaultGroup)15 ArrayList (java.util.ArrayList)14 GroupOperation (org.onosproject.net.group.GroupOperation)10 Instruction (org.onosproject.net.flow.instructions.Instruction)9 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)9 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)8 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 ArrayDeque (java.util.ArrayDeque)7