Search in sources :

Example 41 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.

the class PwaasUtilTest method verifyPolicyEmptyInnerCp2.

@Test
public void verifyPolicyEmptyInnerCp2() {
    cp1 = new ConnectPoint(DID1, PN1);
    cp2 = new ConnectPoint(DID2, PN2);
    ingressInner = VlanId.NONE;
    ingressOuter = VlanId.NONE;
    egressInner = VlanId.NONE;
    egressOuter = V1;
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage(String.format(PwaasUtil.ERR_EMPTY_INNER_WHEN_OUTER_PRESENT, TUNNEL_ID, "cp2"));
    PwaasUtil.verifyPolicy(cp1, cp2, ingressInner, ingressOuter, egressInner, egressOuter, TUNNEL_ID);
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 42 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.

the class PwaasUtil method verifyGlobalValidity.

/**
 * Verifies that the pseudowires will not conflict with each other.
 *
 * Further, check if vlans for connect points are already used.
 *
 * @param tunnel Tunnel for pw
 * @param policy Policy for pw
 * @param labelSet Label set used so far with this configuration
 * @param vlanSet Vlan set used with this configuration
 * @param tunnelSet Tunnel set used with this configuration
 */
private static void verifyGlobalValidity(L2Tunnel tunnel, L2TunnelPolicy policy, Set<MplsLabel> labelSet, Map<ConnectPoint, Set<VlanId>> vlanSet, Set<Long> tunnelSet) {
    if (tunnelSet.contains(tunnel.tunnelId())) {
        throw new IllegalArgumentException(String.valueOf(String.format("Tunnel Id %d already used by" + " another pseudowire, in " + "pseudowire %d!", tunnel.tunnelId(), tunnel.tunnelId())));
    }
    tunnelSet.add(tunnel.tunnelId());
    // check if tunnel id is used again
    ConnectPoint cP1 = policy.cP1();
    ConnectPoint cP2 = policy.cP2();
    // insert cps to hashmap if this is the first time seen
    if (!vlanSet.containsKey(cP1)) {
        vlanSet.put(cP1, new HashSet<VlanId>());
    }
    if (!vlanSet.containsKey(cP2)) {
        vlanSet.put(cP2, new HashSet<VlanId>());
    }
    // if single tagged or untagged vlan is the inner
    // if double tagged vlan is the outer
    VlanId vlanToCheckCP1;
    if (policy.cP1OuterTag().equals(VlanId.NONE)) {
        vlanToCheckCP1 = policy.cP1InnerTag();
    } else {
        vlanToCheckCP1 = policy.cP1OuterTag();
    }
    VlanId vlanToCheckCP2;
    if (policy.cP2OuterTag().equals(VlanId.NONE)) {
        vlanToCheckCP2 = policy.cP2InnerTag();
    } else {
        vlanToCheckCP2 = policy.cP2OuterTag();
    }
    if (labelSet.contains(tunnel.pwLabel())) {
        throw new IllegalArgumentException(String.valueOf(String.format("Label %s already used by another" + " pseudowire, in pseudowire %d!", tunnel.pwLabel(), tunnel.tunnelId())));
    }
    labelSet.add(tunnel.pwLabel());
    if (vlanSet.get(cP1).contains(vlanToCheckCP1)) {
        throw new IllegalArgumentException(String.valueOf(String.format("Vlan '%s' for cP1 %s already used " + "by another pseudowire, in " + "pseudowire" + " %d!", vlanToCheckCP1, cP1, tunnel.tunnelId())));
    }
    vlanSet.get(cP1).add(vlanToCheckCP1);
    if (vlanSet.get(cP2).contains(vlanToCheckCP2)) {
        throw new IllegalArgumentException(String.valueOf(String.format("Vlan '%s' for cP2 %s already used" + " by another pseudowire, in" + " pseudowire %d!", vlanToCheckCP2, cP2, tunnel.tunnelId())));
    }
    vlanSet.get(cP2).add(vlanToCheckCP2);
    if (intfService == null) {
        throw new IllegalStateException(String.format(ERR_SERVICE_UNAVAIL, "InterfaceService"));
    }
    // check that vlans for the connect points are not used
    intfService.getInterfacesByPort(cP1).stream().forEach(intf -> {
        // check if tagged pw affects tagged interface
        if (intf.vlanTagged().contains(vlanToCheckCP1)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Vlan '%s' for cP1 %s already" + " used for this" + " interface, in" + " pseudowire %d!", vlanToCheckCP1, cP1, tunnel.tunnelId())));
        }
        // check if it collides with untagged interface
        if ((intf.vlanNative() != null) && vlanToCheckCP1.equals(VlanId.NONE)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Untagged traffic for cP1 " + "%s already used " + "for this " + "interface, in " + "pseudowire " + "%d!", cP1, tunnel.tunnelId())));
        }
        // check if it collides with untagged interface
        if ((intf.vlanUntagged() != null) && vlanToCheckCP1.equals(VlanId.NONE)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Untagged traffic for " + "cP1 %s already" + " used for this" + " interface," + " in pseudowire %d!", cP1, tunnel.tunnelId())));
        }
    });
    intfService.getInterfacesByPort(cP2).stream().forEach(intf -> {
        if (intf.vlanTagged().contains(vlanToCheckCP2)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Vlan '%s' for cP2 %s " + " used for  " + "this interface, " + "in pseudowire %d!", vlanToCheckCP2, cP2, tunnel.tunnelId())));
        }
        // check if it collides with untagged interface
        if ((intf.vlanNative() != null) && vlanToCheckCP2.equals(VlanId.NONE)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Untagged traffic " + "for cP2 %s " + "already " + "used for this" + " interface, " + "in pseudowire %d!", cP2, tunnel.tunnelId())));
        }
        // check if it collides with untagged interface
        if ((intf.vlanUntagged() != null) && vlanToCheckCP2.equals(VlanId.NONE)) {
            throw new IllegalArgumentException(String.valueOf(String.format("Untagged traffic for cP2 %s" + " already" + " used for " + "this interface, " + "in pseudowire %d!", cP2, tunnel.tunnelId())));
        }
    });
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) VlanId(org.onlab.packet.VlanId)

Example 43 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class DcsBasedTapiConnectionManager method createConnection.

@Override
public TapiConnectionHandler createConnection(TapiNepPair neps) {
    // Calculate route
    TapiConnection connection = connectionController.pathCompute(neps);
    log.debug("Calculated path: {}", connection);
    createConnectionRecursively(connection);
    /*
         * RCAS Create Intent: Assume that if the result of the pathCompute is flat
         * and there are no lower connections, it has to be mapped to an intent
         * It is a connection between line ports (OCh) with an OpticalConnectivity
         * Intent.
         */
    if (connection.getLowerConnections().isEmpty()) {
        TapiNepRef left = neps.left();
        TapiNepRef right = neps.right();
        ConnectPoint leftConnectPoint = left.getConnectPoint();
        ConnectPoint rightConnectPoint = right.getConnectPoint();
        log.debug("Creating Intent from {} to {} {}", leftConnectPoint, rightConnectPoint, connectionHandler.getId());
        notifyTapiConnectivityChange(connectionHandler.getId().toString(), leftConnectPoint, rightConnectPoint, true);
    }
    return connectionHandler;
}
Also used : TapiConnection(org.onosproject.odtn.utils.tapi.TapiConnection) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 44 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class DefaultTapiResolver method getNepRef.

@Override
public TapiNepRef getNepRef(ConnectPoint cp) throws NoSuchElementException {
    updateCache();
    TapiNepRef ret = null;
    try {
        ret = tapiNepRefList.stream().filter(nep -> nep.getConnectPoint() != null && nep.getConnectPoint().equals(cp)).findFirst().get();
    } catch (NoSuchElementException e) {
        log.error("Nep not found associated with {}", cp);
        throw e;
    }
    return ret;
}
Also used : Logger(org.slf4j.Logger) TapiResolver(org.onosproject.odtn.TapiResolver) Deactivate(org.osgi.service.component.annotations.Deactivate) ElementId(org.onosproject.net.ElementId) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) ConnectPoint(org.onosproject.net.ConnectPoint) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) List(java.util.List) Stream(java.util.stream.Stream) Map(java.util.Map) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Activate(org.osgi.service.component.annotations.Activate) NoSuchElementException(java.util.NoSuchElementException) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) NoSuchElementException(java.util.NoSuchElementException)

Example 45 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class TapiNepHandler method setPort.

public TapiNepHandler setPort(Port port) {
    ConnectPoint cp = new ConnectPoint(port.element().id(), port.number());
    kvs.put(ODTN_PORT_TYPE, port.annotations().value(ODTN_PORT_TYPE));
    kvs.put(CONNECTION_ID, port.annotations().value(CONNECTION_ID));
    addNameList(obj, kvs);
    return setConnectPoint(cp);
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)536 Test (org.junit.Test)149 DeviceId (org.onosproject.net.DeviceId)125 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)91 Link (org.onosproject.net.Link)88 Set (java.util.Set)86 PortNumber (org.onosproject.net.PortNumber)86 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)83 VlanId (org.onlab.packet.VlanId)78 TrafficSelector (org.onosproject.net.flow.TrafficSelector)75 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)72 Logger (org.slf4j.Logger)71 Port (org.onosproject.net.Port)70 List (java.util.List)69 Ethernet (org.onlab.packet.Ethernet)69 DeviceService (org.onosproject.net.device.DeviceService)67 Collectors (java.util.stream.Collectors)66 MacAddress (org.onlab.packet.MacAddress)64 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)64 Intent (org.onosproject.net.intent.Intent)62