Search in sources :

Example 36 with GroupId

use of org.onosproject.core.GroupId in project onos by opennetworkinglab.

the class OpenFlowGroupProviderTest method groupModFailure.

@Test
public void groupModFailure() {
    TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService;
    GroupId groupId = new GroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);
    provider.performGroupOperation(deviceId, operations);
    OFGroupModFailedErrorMsg.Builder errorBuilder = OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg();
    OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify();
    groupBuilder.setGroupType(OFGroupType.ALL);
    groupBuilder.setGroup(OFGroup.of(1));
    errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS);
    errorBuilder.setXid(provider.getXidAndAdd(0) - 1);
    controller.processPacket(dpid1, errorBuilder.build());
    assertNotNull("Operation failed should not be null", testProviderService.failedOperation);
}
Also used : OFGroupModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) OFGroupMod(org.projectfloodlight.openflow.protocol.OFGroupMod) GroupOperations(org.onosproject.net.group.GroupOperations) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Example 37 with GroupId

use of org.onosproject.core.GroupId in project onos by opennetworkinglab.

the class OvsdbTunnelProviderTest method testTunnelRemoved.

@Test
public void testTunnelRemoved() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel1"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelRemoved(tunnel);
    assertEquals(0, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 38 with GroupId

use of org.onosproject.core.GroupId in project onos by opennetworkinglab.

the class DefaultTunnelTest method testEquality.

@Test
public void testEquality() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
    GroupId groupId = new GroupId(92034);
    TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
    TunnelId tunnelId = TunnelId.valueOf("41654654");
    ProviderId producerName1 = new ProviderId("producer1", "13");
    ProviderId producerName2 = new ProviderId("producer2", "13");
    Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
    Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
    Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
    new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3).testEquals();
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) EqualsTester(com.google.common.testing.EqualsTester) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 39 with GroupId

use of org.onosproject.core.GroupId in project onos by opennetworkinglab.

the class TunnelEventTest method testConstructor.

/**
 * Checks the operation of equals(), hashCode() and toString() methods.
 */
@Test
public void testConstructor() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
    GroupId groupId = new GroupId(92034);
    TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
    TunnelId tunnelId = TunnelId.valueOf("41654654");
    ProviderId producerName1 = new ProviderId("producer1", "13");
    Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
    TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
    assertThat(e1, is(notNullValue()));
    assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
    assertThat(e1.subject(), is(p1));
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 40 with GroupId

use of org.onosproject.core.GroupId in project onos by opennetworkinglab.

the class DistributedGroupStore method storeGroupDescriptionInternal.

private void storeGroupDescriptionInternal(GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }
    synchronized (deviceAuditStatus) {
        if (deviceAuditStatus.get(groupDesc.deviceId()) == null) {
            // Device group audit has not completed yet
            // Add this group description to pending group key table
            // Create a group entry object with Dummy Group ID
            log.debug("storeGroupDescriptionInternal: Device {} AUDIT pending...Queuing Group id {} ADD request", groupDesc.deviceId(), groupDesc.givenGroupId() != null ? "0x" + Integer.toHexString(groupDesc.givenGroupId()) : "N/A");
            StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc);
            group.setState(GroupState.WAITING_AUDIT_COMPLETE);
            Map<GroupStoreKeyMapKey, StoredGroupEntry> pendingKeyTable = getPendingGroupKeyTable();
            pendingKeyTable.put(new GroupStoreKeyMapKey(groupDesc.deviceId(), groupDesc.appCookie()), group);
            return;
        }
    }
    Group matchingExtraneousGroup = null;
    if (groupDesc.givenGroupId() != null) {
        // Check if there is a extraneous group existing with the same Id
        matchingExtraneousGroup = getMatchingExtraneousGroupbyId(groupDesc.deviceId(), groupDesc.givenGroupId());
        if (matchingExtraneousGroup != null) {
            log.debug("storeGroupDescriptionInternal: Matching extraneous group " + "found in Device {} for group id 0x{}", groupDesc.deviceId(), Integer.toHexString(groupDesc.givenGroupId()));
            // Check if the group buckets matches with user provided buckets
            if (matchingExtraneousGroup.buckets().equals(groupDesc.buckets())) {
                // Group is already existing with the same buckets and Id
                // Create a group entry object
                log.debug("storeGroupDescriptionInternal: Buckets also matching " + "in Device {} for group id 0x{}", groupDesc.deviceId(), Integer.toHexString(groupDesc.givenGroupId()));
                StoredGroupEntry group = new DefaultGroup(matchingExtraneousGroup.id(), groupDesc);
                // Insert the newly created group entry into key and id maps
                getGroupStoreKeyMap().put(new GroupStoreKeyMapKey(groupDesc.deviceId(), groupDesc.appCookie()), group);
                // Ensure it also inserted into group id based table to
                // avoid any chances of duplication in group id generation
                getGroupIdTable(groupDesc.deviceId()).put(matchingExtraneousGroup.id(), group);
                addOrUpdateGroupEntry(matchingExtraneousGroup);
                removeExtraneousGroupEntry(matchingExtraneousGroup);
                return;
            } else {
                // Group buckets are not matching. Update group
                // with user provided buckets.
                log.debug("storeGroupDescriptionInternal: Buckets are not " + "matching in Device {} for group id 0x{}", groupDesc.deviceId(), Integer.toHexString(groupDesc.givenGroupId()));
                StoredGroupEntry modifiedGroup = new DefaultGroup(matchingExtraneousGroup.id(), groupDesc);
                modifiedGroup.setState(GroupState.PENDING_UPDATE);
                getGroupStoreKeyMap().put(new GroupStoreKeyMapKey(groupDesc.deviceId(), groupDesc.appCookie()), modifiedGroup);
                // Ensure it also inserted into group id based table to
                // avoid any chances of duplication in group id generation
                getGroupIdTable(groupDesc.deviceId()).put(matchingExtraneousGroup.id(), modifiedGroup);
                removeExtraneousGroupEntry(matchingExtraneousGroup);
                log.debug("storeGroupDescriptionInternal: Triggering Group " + "UPDATE request for {} in device {}", matchingExtraneousGroup.id(), groupDesc.deviceId());
                notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_REQUESTED, modifiedGroup));
                return;
            }
        }
    } else {
        // Check if there is an extraneous group with user provided buckets
        matchingExtraneousGroup = getMatchingExtraneousGroupbyBuckets(groupDesc.deviceId(), groupDesc.buckets());
        if (matchingExtraneousGroup != null) {
            // Group is already existing with the same buckets.
            // So reuse this group.
            log.debug("storeGroupDescriptionInternal: Matching extraneous group found in Device {}", groupDesc.deviceId());
            // Create a group entry object
            StoredGroupEntry group = new DefaultGroup(matchingExtraneousGroup.id(), groupDesc);
            // Insert the newly created group entry into key and id maps
            getGroupStoreKeyMap().put(new GroupStoreKeyMapKey(groupDesc.deviceId(), groupDesc.appCookie()), group);
            // Ensure it also inserted into group id based table to
            // avoid any chances of duplication in group id generation
            getGroupIdTable(groupDesc.deviceId()).put(matchingExtraneousGroup.id(), group);
            addOrUpdateGroupEntry(matchingExtraneousGroup);
            removeExtraneousGroupEntry(matchingExtraneousGroup);
            return;
        } else {
            // TODO: Check if there are any empty groups that can be used here
            log.debug("storeGroupDescriptionInternal: No matching extraneous groups found in Device {}", groupDesc.deviceId());
        }
    }
    GroupId id = null;
    if (groupDesc.givenGroupId() == null) {
        // Get a new group identifier
        id = new GroupId(getFreeGroupIdValue(groupDesc.deviceId()));
    } else {
        // we need to use the identifier passed in by caller, but check if
        // already used
        Group existing = getGroup(groupDesc.deviceId(), new GroupId(groupDesc.givenGroupId()));
        if (existing != null) {
            log.warn("Group already exists with the same id: 0x{} in dev:{} " + "but with different key: {} (request gkey: {})", Integer.toHexString(groupDesc.givenGroupId()), groupDesc.deviceId(), existing.appCookie(), groupDesc.appCookie());
            return;
        }
        id = new GroupId(groupDesc.givenGroupId());
    }
    // Create a group entry object
    StoredGroupEntry group = new DefaultGroup(id, groupDesc);
    // Insert the newly created group entry into key and id maps
    getGroupStoreKeyMap().put(new GroupStoreKeyMapKey(groupDesc.deviceId(), groupDesc.appCookie()), group);
    // Ensure it also inserted into group id based table to
    // avoid any chances of duplication in group id generation
    getGroupIdTable(groupDesc.deviceId()).put(id, group);
    log.debug("storeGroupDescriptionInternal: Processing Group ADD request for Id {} in device {}", id, groupDesc.deviceId());
    notifyDelegate(new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED, group));
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) DefaultGroup(org.onosproject.net.group.DefaultGroup) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent) GroupId(org.onosproject.core.GroupId)

Aggregations

GroupId (org.onosproject.core.GroupId)59 GroupBucket (org.onosproject.net.group.GroupBucket)30 GroupKey (org.onosproject.net.group.GroupKey)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)26 GroupBuckets (org.onosproject.net.group.GroupBuckets)26 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)25 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)24 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)21 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)19 GroupDescription (org.onosproject.net.group.GroupDescription)19 DefaultGroup (org.onosproject.net.group.DefaultGroup)18 Group (org.onosproject.net.group.Group)17 GroupEvent (org.onosproject.net.group.GroupEvent)12 ArrayList (java.util.ArrayList)11 PortNumber (org.onosproject.net.PortNumber)11 Instruction (org.onosproject.net.flow.instructions.Instruction)10 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)10 StoredGroupEntry (org.onosproject.net.group.StoredGroupEntry)10 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)9 MacAddress (org.onlab.packet.MacAddress)8