use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentKeyImrCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
IntentService service = AbstractShellCommand.get(IntentService.class);
SortedSet<String> strings = delegate.getStrings();
service.getIntents().forEach(intent -> {
if (intent instanceof LinkCollectionIntent || intent instanceof PointToPointIntent) {
strings.add(intent.key().toString());
}
});
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
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);
}
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);
}
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);
});
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PeerConnectivityManager method buildIntents.
/**
* Builds the required intents between a BGP speaker and an external router.
*
* @param portOne the BGP speaker connect point
* @param vlanOne the BGP speaker VLAN
* @param ipOne the BGP speaker IP address
* @param portTwo the external BGP peer connect point
* @param vlanTwo the external BGP peer VLAN
* @param ipTwo the external BGP peer IP address
* @param encap the encapsulation type
* @return the intents to install
*/
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, VlanId vlanOne, IpAddress ipOne, ConnectPoint portTwo, VlanId vlanTwo, IpAddress ipTwo, EncapsulationType encap) {
List<PointToPointIntent> intents = new ArrayList<>();
TrafficTreatment.Builder treatmentToPeer = DefaultTrafficTreatment.builder();
TrafficTreatment.Builder treatmentToSpeaker = DefaultTrafficTreatment.builder();
PointToPointIntent.Builder intentBuilder;
TrafficSelector selector;
Key key;
byte tcpProtocol;
byte icmpProtocol;
if (ipOne.isIp4()) {
tcpProtocol = IPv4.PROTOCOL_TCP;
icmpProtocol = IPv4.PROTOCOL_ICMP;
} else {
tcpProtocol = IPv6.PROTOCOL_TCP;
icmpProtocol = IPv6.PROTOCOL_ICMP6;
}
// Add VLAN treatment for traffic going from BGP speaker to BGP peer
treatmentToPeer = applyVlanTreatment(vlanOne, vlanTwo, treatmentToPeer);
// Path from BGP speaker to BGP peer matching destination TCP port 179
selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, null, BGP_PORT);
key = buildKey(ipOne, ipTwo, SUFFIX_DST);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Path from BGP speaker to BGP peer matching source TCP port 179
selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, BGP_PORT, null);
key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// ICMP path from BGP speaker to BGP peer
selector = buildSelector(icmpProtocol, vlanOne, ipOne, ipTwo, null, null);
key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Add VLAN treatment for traffic going from BGP peer to BGP speaker
treatmentToSpeaker = applyVlanTreatment(vlanTwo, vlanOne, treatmentToSpeaker);
// Path from BGP peer to BGP speaker matching destination TCP port 179
selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, null, BGP_PORT);
key = buildKey(ipTwo, ipOne, SUFFIX_DST);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// Path from BGP peer to BGP speaker matching source TCP port 179
selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, BGP_PORT, null);
key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
// ICMP path from BGP peer to BGP speaker
selector = buildSelector(icmpProtocol, vlanTwo, ipTwo, ipOne, null, null);
key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
encap(intentBuilder, encap);
intents.add(intentBuilder.build());
return intents;
}
Aggregations