use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class SdnIpCommand method setEncap.
/**
* Sets the encapsulation type for SDN-IP.
*
* @param encap the encapsulation type
*/
private void setEncap(String encap) {
EncapsulationType encapType = EncapsulationType.enumFromString(encap);
if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) {
print(ENCAP_NOT_FOUND, encap);
return;
}
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(SdnIp.SDN_IP_APP);
SdnIpConfig config = configService.addConfig(appId, SdnIpConfig.class);
config.setEncap(encapType);
config.apply();
// configService.applyConfig(appId, SdnIpConfig.class, config.node());
}
use of org.onosproject.net.EncapsulationType in project onos by opennetworkinglab.
the class PeerConnectivityManager method setUpConnectivity.
/**
* Sets up paths to establish connectivity between all internal
* BGP speakers and external BGP peers.
*/
private void setUpConnectivity() {
BgpConfig bgpConfig = configService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
SdnIpConfig sdnIpConfig = configService.getConfig(appId, SdnIpConfig.class);
Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers;
EncapsulationType encap;
if (bgpConfig == null) {
log.debug("No BGP config available");
bgpSpeakers = Collections.emptySet();
} else {
bgpSpeakers = bgpConfig.bgpSpeakers();
}
if (sdnIpConfig == null) {
log.debug("No SDN-IP config available");
encap = EncapsulationType.NONE;
} else {
encap = sdnIpConfig.encap();
}
Map<Key, PointToPointIntent> existingIntents = new HashMap<>(peerIntents);
for (BgpConfig.BgpSpeakerConfig bgpSpeaker : bgpSpeakers) {
log.debug("Start to set up BGP paths for BGP speaker: {}", bgpSpeaker);
buildSpeakerIntents(bgpSpeaker, encap).forEach(i -> {
PointToPointIntent intent = existingIntents.remove(i.key());
if (intent == null || !IntentUtils.intentsAreEqual(i, intent)) {
peerIntents.put(i.key(), i);
intentSynchronizer.submit(i);
}
});
}
// Remove any remaining intents that we used to have that we don't need
// anymore
existingIntents.values().forEach(i -> {
peerIntents.remove(i.key());
intentSynchronizer.withdraw(i);
});
}
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 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