use of org.onosproject.routing.config.BgpConfig 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.routing.config.BgpConfig in project onos by opennetworkinglab.
the class RemovePeerCommand method doExecute.
@Override
protected void doExecute() {
peerAddress = IpAddress.valueOf(ip);
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
peerAddress = IpAddress.valueOf(ip);
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerFromPeer(peerAddress);
if (speaker == null) {
print(PEER_NOT_FOUND, ip);
return;
}
removePeerFromSpeakerConf(speaker, config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(PEER_REMOVE_SUCCESS);
}
use of org.onosproject.routing.config.BgpConfig in project onos by opennetworkinglab.
the class AddPeerCommand method doExecute.
@Override
protected void doExecute() {
peerAddress = IpAddress.valueOf(ip);
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
if (speaker == null) {
print(SPEAKER_NOT_FOUND, name);
return;
} else {
if (speaker.isConnectedToPeer(peerAddress)) {
// Peering already exists.
return;
}
}
InterfaceService interfaceService = get(InterfaceService.class);
if (interfaceService.getMatchingInterface(peerAddress) == null) {
print(NO_INTERFACE, ip);
return;
}
addPeerToSpeakerConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(PEER_ADD_SUCCESS);
}
Aggregations