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);
}
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())));
}
});
}
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;
}
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;
}
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);
}
Aggregations