Search in sources :

Example 16 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent 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)

Example 17 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class PeerConnectivityManagerTest method icmpPathintentConstructor.

/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void icmpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_ICMP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(srcVlanId);
    }
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }
    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + "icmp", APPID);
    PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
    intentList.add(intent);
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 18 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class PeerConnectivityManagerTest method bgpPathintentConstructor.

/**
 * Constructs a BGP intent and put it into the intentList.
 * <p/>
 * The purpose of this method is too simplify the setUpBgpIntents() method,
 * and to make the setUpBgpIntents() easy to read.
 *
 * @param srcVlanId ingress VlanId
 * @param dstVlanId egress VlanId
 * @param srcPrefix source IP prefix to match
 * @param dstPrefix destination IP prefix to match
 * @param srcTcpPort source TCP port to match
 * @param dstTcpPort destination TCP port to match
 * @param srcConnectPoint source connect point for PointToPointIntent
 * @param dstConnectPoint destination connect point for PointToPointIntent
 */
private void bgpPathintentConstructor(VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, Short srcTcpPort, Short dstTcpPort, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).matchIPProtocol(IPv4.PROTOCOL_TCP).matchIPSrc(IpPrefix.valueOf(srcPrefix)).matchIPDst(IpPrefix.valueOf(dstPrefix));
    if (!srcVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(srcVlanId);
    }
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    if (!dstVlanId.equals(VlanId.NONE)) {
        treatment.setVlanId(dstVlanId);
    }
    if (srcTcpPort != null) {
        builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
    }
    if (dstTcpPort != null) {
        builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
    }
    Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID);
    PointToPointIntent intent = PointToPointIntent.builder().appId(APPID).key(key).selector(builder.build()).treatment(treatment.build()).filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint)).filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint)).build();
    intentList.add(intent);
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 19 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class VbngManager method removeForwardingPaths.

/**
 * Removes the forwarding paths in both two directions between host
 * configured with private IP and next hop.
 *
 * @param privateIp the private IP address of a local host
 */
private void removeForwardingPaths(IpAddress privateIp) {
    PointToPointIntent toNextHopIntent = p2pIntentsFromHost.remove(privateIp);
    if (toNextHopIntent != null) {
        intentService.withdraw(toNextHopIntent);
    // intentService.purge(toNextHopIntent);
    }
    PointToPointIntent toLocalHostIntent = p2pIntentsToHost.remove(privateIp);
    if (toLocalHostIntent != null) {
        intentService.withdraw(toLocalHostIntent);
    // intentService.purge(toLocalHostIntent);
    }
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent)

Example 20 with PointToPointIntent

use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.

the class ConnectivityManager method buildSpeakerIntents.

private Collection<PointToPointIntent> buildSpeakerIntents(Peer speaker, Peer peer) {
    List<PointToPointIntent> intents = new ArrayList<>();
    IpAddress peerAddress = IpAddress.valueOf(peer.getIpAddress());
    IpAddress speakerAddress = IpAddress.valueOf(speaker.getIpAddress());
    checkNotNull(peerAddress);
    intents.addAll(buildIntents(ConnectPoint.deviceConnectPoint(speaker.getPort()), speakerAddress, ConnectPoint.deviceConnectPoint(peer.getPort()), peerAddress));
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) IpAddress(org.onlab.packet.IpAddress)

Aggregations

PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)48 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)28 ConnectPoint (org.onosproject.net.ConnectPoint)24 Intent (org.onosproject.net.intent.Intent)19 Test (org.junit.Test)18 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)16 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 Key (org.onosproject.net.intent.Key)13 ArrayList (java.util.ArrayList)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 Link (org.onosproject.net.Link)11 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)11 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 Constraint (org.onosproject.net.intent.Constraint)11 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)10 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)10 PathIntent (org.onosproject.net.intent.PathIntent)8 MockResourceService (org.onosproject.net.resource.MockResourceService)8 ResourceService (org.onosproject.net.resource.ResourceService)8