use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainEndP2P.
/**
* We test the proper compilation of a domain ending with a domain device.
*/
@Test
public void testCompilationDomainEndP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d1p0, d2p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(2));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p0));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d2p10));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainFullP2P.
/**
* We test the proper compilation of a path fully inside of a domain.
*/
@Test
public void testCompilationDomainFullP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d4p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d4p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d4p10));
assertThat(domainIntent.links(), hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainStartP2P.
/**
* We test the proper compilation of a domain starting with a domain device.
*/
@Test
public void testCompilationDomainStartP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d1p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(2));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d2p0));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class IntentsResourceTest method testIntentsArrayWithoutDetail.
/**
* Tests the result of the rest api GET when intents are defined and the detail flag is false.
*/
@Test
public void testIntentsArrayWithoutDetail() {
replay(mockIntentService);
final PointToPointIntent intent1 = PointToPointIntent.builder().appId(APP_ID).selector(selector1).treatment(treatment1).filteredIngressPoint(new FilteredConnectPoint(connectPoint1)).filteredEgressPoint(new FilteredConnectPoint(connectPoint2)).build();
final HashSet<NetworkResource> resources = new HashSet<>();
resources.add(new MockResource(1));
resources.add(new MockResource(2));
resources.add(new MockResource(3));
final HostToHostIntent intent2 = HostToHostIntent.builder().appId(APP_ID).selector(selector2).treatment(treatment2).one(hostId1).two(hostId2).build();
intents.add(intent1);
intents.add(intent2);
final WebTarget wt = target();
final String response = wt.path("intents").queryParam("detail", false).request().get(String.class);
assertThat(response, containsString("{\"intents\":["));
final JsonObject result = Json.parse(response).asObject();
assertThat(result, notNullValue());
assertThat(result.names(), hasSize(1));
assertThat(result.names().get(0), is("intents"));
final JsonArray jsonIntents = result.get("intents").asArray();
assertThat(jsonIntents, notNullValue());
assertThat(jsonIntents, hasIntent(intent1, false));
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class ConnectivityManager method updateExistingL2Intents.
/**
* Updates the existing layer 2 flows. Whenever a new Peer is added, it is also
* added as the ingress point to the existing layer two flows.
*
* @param peer The Peer being added.
*/
private void updateExistingL2Intents(Peer peer) {
Collection<MultiPointToSinglePointIntent> oldIntents = castorStore.getLayer2Intents().values();
for (MultiPointToSinglePointIntent oldIntent : oldIntents) {
Set<FilteredConnectPoint> ingressPoints = oldIntent.filteredIngressPoints();
ConnectPoint egressPoint = oldIntent.egressPoint();
if (ingressPoints.add(new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(peer.getPort())))) {
MultiPointToSinglePointIntent updatedMp2pIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(oldIntent.key()).selector(oldIntent.selector()).treatment(oldIntent.treatment()).filteredIngressPoints(ingressPoints).filteredEgressPoint(new FilteredConnectPoint(egressPoint)).priority(oldIntent.priority()).build();
// layer2Intents.put(peer.getIpAddress(), updatedMp2pIntent);
castorStore.storeLayer2Intent(peer.getIpAddress(), updatedMp2pIntent);
intentSynchronizer.submit(updatedMp2pIntent);
}
}
}
Aggregations