use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class SdnIpFib method update.
private void update(ResolvedRoute route) {
synchronized (this) {
IpPrefix prefix = route.prefix();
EncapsulationType encap = encap();
MultiPointToSinglePointIntent intent = generateRouteIntent(prefix, route.nextHop(), route.nextHopMac(), encap);
if (intent == null) {
log.debug("No interface found for route {}", route);
return;
}
routeIntents.put(prefix, intent);
intentSynchronizer.submit(intent);
}
}
use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class SdnIpFib method encapUpdate.
/*
* Triggered when the network configuration configuration is modified.
* It checks if the encapsulation type has changed from last time, and in
* case modifies all intents.
*/
private void encapUpdate() {
synchronized (this) {
// Get the encapsulation type just set from the configuration
EncapsulationType encap = encap();
for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
// Get each intent currently registered by SDN-IP
MultiPointToSinglePointIntent intent = entry.getValue();
// Make sure the same constraint is not already part of the
// intent constraints
List<Constraint> constraints = intent.constraints();
if (!constraints.stream().filter(c -> c instanceof EncapsulationConstraint && new EncapsulationConstraint(encap).equals(c)).findAny().isPresent()) {
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder(intent);
// Set the new encapsulation constraint
setEncap(intentBuilder, constraints, encap);
// Build and submit the new intent
MultiPointToSinglePointIntent newIntent = intentBuilder.build();
routeIntents.put(entry.getKey(), newIntent);
intentSynchronizer.submit(newIntent);
}
}
}
}
use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class VplsIntentTest method generateVplsUni.
/**
* Generates a list of expected mp2sp intents for a given VPLS.
*
* @param fcPoints the filtered connect point
* @param hosts the hosts
* @param name the name of the VPLS
* @param encap the encapsulation type
* @return the list of expected mp2sp intents for the given VPLS
*/
private List<MultiPointToSinglePointIntent> generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts, String name, EncapsulationType encap) {
List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();
hosts.forEach(host -> {
FilteredConnectPoint hostPoint = getHostPoint(host, fcPoints);
Set<FilteredConnectPoint> otherPoints = fcPoints.stream().filter(fcp -> !fcp.equals(hostPoint)).collect(Collectors.toSet());
Key uniKey = buildKey(VplsIntentUtility.PREFIX_UNICAST, host.location(), name, host.mac());
intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
});
return intents;
}
use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class VplsIntentUtility method setEncap.
/**
* Sets one or more encapsulation constraints on the intent builder given.
*
* @param builder the intent builder
* @param constraints the existing intent constraints
* @param encap the encapsulation type to be set
*/
public static void setEncap(ConnectivityIntent.Builder builder, List<Constraint> constraints, EncapsulationType encap) {
// Constraints might be an immutable list, so a new modifiable list
// is created
List<Constraint> newConstraints = new ArrayList<>(constraints);
// Remove any encapsulation constraint if already in the list
constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
// constraint should be added to the list
if (!encap.equals(NONE)) {
newConstraints.add(new EncapsulationConstraint(encap));
}
// Submit new constraint list as immutable list
builder.constraints(ImmutableList.copyOf(newConstraints));
}
use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class SimpleFabricRouting method buildConstraints.
// constraints generator
private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encap) {
if (!encap.equals(EncapsulationType.NONE)) {
List<Constraint> newConstraints = new ArrayList<>(constraints);
constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
newConstraints.add(new EncapsulationConstraint(encap));
return ImmutableList.copyOf(newConstraints);
}
return constraints;
}
Aggregations