use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.
the class DefaultL2TunnelHandler method deployPseudoWireTerm.
/**
* Handles the tunnel termination, which consists in the creation
* of a forwarding objective and a next objective.
*
* @param l2Tunnel the tunnel to terminate
* @param egress the egress point
* @param egressVlan the expected vlan at egress
* @param direction the direction
* @return the result of the operation
*/
private Result deployPseudoWireTerm(L2Tunnel l2Tunnel, ConnectPoint egress, VlanId egressVlan, Direction direction, boolean oneHop) {
log.debug("Started deploying termination objectives for pseudowire {} , direction {}.", l2Tunnel.tunnelId(), direction == FWD ? "forward" : "reverse");
// We create the group relative to the termination.
NextObjective.Builder nextObjectiveBuilder = createNextObjective(TERMINATION, egress, null, l2Tunnel, egress.deviceId(), oneHop, egressVlan);
if (nextObjectiveBuilder == null) {
return INTERNAL_ERROR;
}
TrafficSelector metadata = DefaultTrafficSelector.builder().matchVlanId(egressVlan).build();
nextObjectiveBuilder.withMeta(metadata);
int nextId = srManager.flowObjectiveService.allocateNextId();
if (nextId < 0) {
log.warn("Not able to allocate a next id for initiation");
return INTERNAL_ERROR;
}
nextObjectiveBuilder.withId(nextId);
String key = generateKey(l2Tunnel.tunnelId(), direction);
l2TerminationNextObjStore.put(key, nextObjectiveBuilder.add());
ObjectiveContext context = new DefaultObjectiveContext((objective) -> log.debug("Termination l2 tunnel rule for {} populated", l2Tunnel.tunnelId()), (objective, error) -> {
log.warn("Failed to populate termination l2 tunnel rule for {}: {}", l2Tunnel.tunnelId(), error);
srManager.invalidateNextObj(objective.id());
});
NextObjective nextObjective = nextObjectiveBuilder.add(context);
srManager.flowObjectiveService.next(egress.deviceId(), nextObjective);
log.debug("Termination next objective for {} not found. Creating new NextObj with id={}", l2Tunnel.tunnelId(), nextObjective.id());
// We create the flow relative to the termination.
ForwardingObjective.Builder fwdBuilder = createTermFwdObjective(l2Tunnel.pwLabel(), l2Tunnel.tunnelId(), egress.port(), nextObjective.id());
context = new DefaultObjectiveContext((objective) -> log.debug("FwdObj for tunnel termination {} populated", l2Tunnel.tunnelId()), (objective, error) -> log.warn("Failed to populate fwdrObj" + " for tunnel termination {} : {}", l2Tunnel.tunnelId(), error));
srManager.flowObjectiveService.forward(egress.deviceId(), fwdBuilder.add(context));
log.debug("Creating new FwdObj for termination NextObj with id={} for tunnel {}", nextId, l2Tunnel.tunnelId());
return SUCCESS;
}
use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.
the class PwaasUtilTest method verifyPolicyPortNotFound.
@Test
public void verifyPolicyPortNotFound() {
cp1 = new ConnectPoint(DID1, PN99);
cp2 = new ConnectPoint(DID2, PN2);
ingressInner = V1;
ingressOuter = V2;
egressInner = V1;
egressOuter = V2;
exception.expect(IllegalArgumentException.class);
exception.expectMessage(String.format(PwaasUtil.ERR_PORT_NOT_FOUND, PN99, DID1, TUNNEL_ID));
PwaasUtil.verifyPolicy(cp1, cp2, ingressInner, ingressOuter, egressInner, egressOuter, TUNNEL_ID);
}
use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.
the class PwaasUtilTest method verifyPolicyOnSameDevice.
@Test
public void verifyPolicyOnSameDevice() {
cp1 = new ConnectPoint(DID1, PN1);
cp2 = new ConnectPoint(DID1, PN2);
ingressInner = VlanId.NONE;
ingressOuter = VlanId.NONE;
egressInner = VlanId.NONE;
egressOuter = VlanId.NONE;
exception.expect(IllegalArgumentException.class);
exception.expectMessage(String.format(PwaasUtil.ERR_SAME_DEV, TUNNEL_ID));
PwaasUtil.verifyPolicy(cp1, cp2, ingressInner, ingressOuter, egressInner, egressOuter, TUNNEL_ID);
}
use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.
the class PwaasUtilTest method verifyPolicyVlanWildcard.
@Test
public void verifyPolicyVlanWildcard() {
cp1 = new ConnectPoint(DID1, PN1);
cp2 = new ConnectPoint(DID2, PN2);
ingressInner = VlanId.ANY;
ingressOuter = VlanId.NONE;
egressInner = VlanId.NONE;
egressOuter = VlanId.NONE;
exception.expect(IllegalArgumentException.class);
exception.expectMessage(String.format(PwaasUtil.ERR_WILDCARD_VLAN, TUNNEL_ID));
PwaasUtil.verifyPolicy(cp1, cp2, ingressInner, ingressOuter, egressInner, egressOuter, TUNNEL_ID);
}
use of org.onosproject.net.ConnectPoint in project trellis-control by opennetworkinglab.
the class PwaasUtilTest method verifyPolicySingleToUntagged.
@Test
public void verifyPolicySingleToUntagged() {
cp1 = new ConnectPoint(DID1, PN1);
cp2 = new ConnectPoint(DID2, PN2);
ingressInner = V1;
ingressOuter = VlanId.NONE;
egressInner = VlanId.NONE;
egressOuter = VlanId.NONE;
exception.expect(IllegalArgumentException.class);
exception.expectMessage(String.format(PwaasUtil.ERR_SINGLE_TO_UNTAGGED, TUNNEL_ID));
PwaasUtil.verifyPolicy(cp1, cp2, ingressInner, ingressOuter, egressInner, egressOuter, TUNNEL_ID);
}
Aggregations