Search in sources :

Example 1 with BgpConfig

use of org.onosproject.routing.config.BgpConfig in project onos by opennetworkinglab.

the class AddSpeakerCommand method doExecute.

@Override
protected void doExecute() {
    NetworkConfigService configService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
    BgpConfig config = configService.addConfig(appId, BgpConfig.class);
    if (name != null) {
        BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
        if (speaker != null) {
            log.debug("Speaker already exists: {}", name);
            return;
        }
    }
    if (vlanId == null || vlanId.isEmpty()) {
        vlanIdObj = VlanId.NONE;
    } else {
        vlanIdObj = VlanId.vlanId(Short.valueOf(vlanId));
    }
    addSpeakerToConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());
    print(SPEAKER_ADD_SUCCESS);
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with BgpConfig

use of org.onosproject.routing.config.BgpConfig in project onos by opennetworkinglab.

the class BgpSpeakersListCommand method doExecute.

@Override
protected void doExecute() {
    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) {
        print("No speakers configured");
        return;
    }
    List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
    Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
    if (config.bgpSpeakers().isEmpty()) {
        print("No speakers configured");
    } else {
        bgpSpeakers.forEach(s -> {
            if (s.name().isPresent()) {
                print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
            } else {
                print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
            }
        });
    }
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 3 with BgpConfig

use of org.onosproject.routing.config.BgpConfig in project onos by opennetworkinglab.

the class RemoveSpeakerCommand method doExecute.

@Override
protected void doExecute() {
    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.peers().isEmpty()) {
            // Removal not allowed when peer connections exist.
            print(PEERS_EXIST, name);
            return;
        }
    }
    removeSpeakerFromConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());
    print(SPEAKER_REMOVE_SUCCESS);
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 4 with BgpConfig

use of org.onosproject.routing.config.BgpConfig in project onos by opennetworkinglab.

the class BgpSpeakerNeighbourHandler method configureSpeakerHandlers.

private void configureSpeakerHandlers() {
    BgpConfig config = configService.getConfig(appId, RoutingService.CONFIG_CLASS);
    if (config == null) {
        return;
    }
    speakerConnectPoints.forEach(cp -> neighbourService.unregisterNeighbourHandler(cp, internalHandler, appId));
    speakerConnectPoints.clear();
    config.bgpSpeakers().forEach(speaker -> {
        neighbourService.registerNeighbourHandler(speaker.connectPoint(), internalHandler, appId);
        speakerConnectPoints.add(speaker.connectPoint());
    });
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig)

Example 5 with BgpConfig

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);
    });
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) EncapsulationType(org.onosproject.net.EncapsulationType) HashMap(java.util.HashMap) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Key(org.onosproject.net.intent.Key)

Aggregations

BgpConfig (org.onosproject.routing.config.BgpConfig)8 ApplicationId (org.onosproject.core.ApplicationId)6 CoreService (org.onosproject.core.CoreService)6 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)6 InterfaceService (org.onosproject.net.intf.InterfaceService)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 DefaultByteArrayNodeFactory (com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory)1 ConcurrentInvertedRadixTree (com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree)1 InvertedRadixTree (com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Ip4Address (org.onlab.packet.Ip4Address)1 Ip6Address (org.onlab.packet.Ip6Address)1 IpAddress (org.onlab.packet.IpAddress)1 IpPrefix (org.onlab.packet.IpPrefix)1 MacAddress (org.onlab.packet.MacAddress)1 ConnectPoint (org.onosproject.net.ConnectPoint)1