Search in sources :

Example 1 with SdnIpConfig

use of org.onosproject.sdnip.config.SdnIpConfig 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());
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with SdnIpConfig

use of org.onosproject.sdnip.config.SdnIpConfig 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

EncapsulationType (org.onosproject.net.EncapsulationType)2 SdnIpConfig (org.onosproject.sdnip.config.SdnIpConfig)2 HashMap (java.util.HashMap)1 ApplicationId (org.onosproject.core.ApplicationId)1 CoreService (org.onosproject.core.CoreService)1 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)1 Key (org.onosproject.net.intent.Key)1 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)1 BgpConfig (org.onosproject.routing.config.BgpConfig)1