Search in sources :

Example 86 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class ConnectivityManager method buildIntents.

/**
 * Builds the required intents between the two pairs of connect points and
 * IP addresses.
 *
 * @param portOne the first connect point
 * @param ipOne the first IP address
 * @param portTwo the second connect point
 * @param ipTwo the second IP address
 * @return the intents to install
 */
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, IpAddress ipOne, ConnectPoint portTwo, IpAddress ipTwo) {
    List<PointToPointIntent> intents = new ArrayList<>();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    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;
    }
    // Path from BGP speaker to BGP peer matching source TCP port 179
    selector = buildSelector(tcpProtocol, ipOne, ipTwo, BGP_PORT, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
    intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).priority(PRIORITY_OFFSET).build());
    // Path from BGP peer to BGP speaker matching destination TCP port 179
    selector = buildSelector(tcpProtocol, ipTwo, ipOne, null, BGP_PORT);
    key = buildKey(ipTwo, ipOne, SUFFIX_DST);
    intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).priority(PRIORITY_OFFSET).build());
    // ICMP path from BGP speaker to BGP peer
    selector = buildSelector(icmpProtocol, ipOne, ipTwo, null, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
    intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).priority(PRIORITY_OFFSET).build());
    // ICMP path from BGP peer to BGP speaker
    selector = buildSelector(icmpProtocol, ipTwo, ipOne, null, null);
    key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
    intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).priority(PRIORITY_OFFSET).build());
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) 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 87 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class PointToPointIntentCodec method decode.

@Override
public PointToPointIntent decode(ObjectNode json, CodecContext context) {
    PointToPointIntent.Builder builder = PointToPointIntent.builder();
    IntentCodec.intentAttributes(json, context, builder);
    ConnectivityIntentCodec.intentAttributes(json, context, builder);
    ObjectNode ingressJson = nullIsIllegal(get(json, INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    ConnectPoint ingress = context.codec(ConnectPoint.class).decode(ingressJson, context);
    builder.filteredIngressPoint(new FilteredConnectPoint(ingress));
    ObjectNode egressJson = nullIsIllegal(get(json, EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    ConnectPoint egress = context.codec(ConnectPoint.class).decode(egressJson, context);
    builder.filteredEgressPoint(new FilteredConnectPoint(egress));
    return builder.build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 88 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class MultiPointToSinglePointIntentCodec method decode.

@Override
public MultiPointToSinglePointIntent decode(ObjectNode json, CodecContext context) {
    MultiPointToSinglePointIntent.Builder builder = MultiPointToSinglePointIntent.builder();
    IntentCodec.intentAttributes(json, context, builder);
    ConnectivityIntentCodec.intentAttributes(json, context, builder);
    ArrayNode ingressJson = nullIsIllegal((ArrayNode) json.get(INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    if (ingressJson != null) {
        final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
        JsonNode connectPointsJson = json.get(INGRESS_POINT);
        Set<FilteredConnectPoint> ingressCp = new HashSet<>();
        if (connectPointsJson != null) {
            for (int i = 0; i < connectPointsJson.size(); i++) {
                ingressCp.add(new FilteredConnectPoint(connectPointCodec.decode(get(connectPointsJson, i), context)));
            }
            builder.filteredIngressPoints(ingressCp);
        }
    }
    ObjectNode egressJson = nullIsIllegal(get(json, EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    ConnectPoint egress = context.codec(ConnectPoint.class).decode(egressJson, context);
    builder.filteredEgressPoint(new FilteredConnectPoint(egress));
    return builder.build();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 89 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method testTwoEgressCompilation.

/**
 * Tests a simple topology where two egress points share some path segments
 * and some path segments are not shared.
 */
@Test
public void testTwoEgressCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo);
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = { S2, S3 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
    assertThat(compiler, is(notNullValue()));
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(4));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
        assertThat(linkIntent.links(), linksHasPath(S3, S5));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 90 with FilteredConnectPoint

use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.

the class DomainIntentInstallerTest method createAnotherDomainIntents.

/**
 * Create another domain Intents.
 *
 * @return the domain Intents
 */
private List<Intent> createAnotherDomainIntents() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
    FilteredConnectPoint egress = new FilteredConnectPoint(CP3);
    DomainPointToPointIntent intent = DomainPointToPointIntent.builder().appId(APP_ID).key(KEY1).priority(DEFAULT_PRIORITY).filteredIngressPoint(ingress).filteredEgressPoint(egress).links(ImmutableList.of()).build();
    return ImmutableList.of(intent);
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)161 Test (org.junit.Test)101 Intent (org.onosproject.net.intent.Intent)101 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)92 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)80 TrafficSelector (org.onosproject.net.flow.TrafficSelector)65 ConnectPoint (org.onosproject.net.ConnectPoint)64 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)53 List (java.util.List)52 Collectors (java.util.stream.Collectors)52 VlanId (org.onlab.packet.VlanId)52 DeviceId (org.onosproject.net.DeviceId)50 FlowRule (org.onosproject.net.flow.FlowRule)50 DomainService (org.onosproject.net.domain.DomainService)48 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)48 ImmutableSet (com.google.common.collect.ImmutableSet)47 LOCAL (org.onosproject.net.domain.DomainId.LOCAL)47 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)47 Before (org.junit.Before)46