use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentsResourceTest method testIntentsArrayWithDetail.
/**
* Tests the result of the rest api GET when intents are defined and the detail flag is true.
*/
@Test
public void testIntentsArrayWithDetail() {
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", true).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, true));
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PeerConnectivityManager method buildSpeakerIntents.
private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker, EncapsulationType encap) {
List<PointToPointIntent> intents = new ArrayList<>();
// Get the BGP Speaker VLAN Id
VlanId bgpSpeakerVlanId = speaker.vlan();
for (IpAddress peerAddress : speaker.peers()) {
Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress);
if (peeringInterface == null) {
log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker);
continue;
}
IpAddress bgpSpeakerAddress = null;
for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
if (address.subnetAddress().contains(peerAddress)) {
bgpSpeakerAddress = address.ipAddress();
break;
}
}
checkNotNull(bgpSpeakerAddress);
VlanId peerVlanId = peeringInterface.vlan();
intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress, encap));
}
return intents;
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class ConnectivityManager method deletel3.
/**
* Delete all the flows between the Peer being deleted and the Route Servers
* to kill the BGP sessions. It uses the keys to retrive the previous intents
* and withdraw them.
*
* @param peer The Peer being deleted.
*/
private void deletel3(Peer peer) {
List<Key> keys = new LinkedList<>();
IpAddress ipTwo = IpAddress.valueOf(peer.getIpAddress());
for (Peer server : castorStore.getServers()) {
IpAddress ipOne = IpAddress.valueOf(server.getIpAddress());
keys.add(buildKey(ipOne, ipTwo, SUFFIX_SRC));
keys.add(buildKey(ipTwo, ipOne, SUFFIX_DST));
keys.add(buildKey(ipOne, ipTwo, SUFFIX_ICMP));
keys.add(buildKey(ipTwo, ipOne, SUFFIX_ICMP));
}
for (Key keyDel : keys) {
PointToPointIntent intent = castorStore.getPeerIntents().get(keyDel);
intentSynchronizer.withdraw(intent);
castorStore.removePeerIntent(keyDel);
}
}
Aggregations