aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/sdnip
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/sdnip')
-rw-r--r--framework/src/onos/apps/sdnip/app.xml24
-rw-r--r--framework/src/onos/apps/sdnip/features.xml25
-rw-r--r--framework/src/onos/apps/sdnip/pom.xml88
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java241
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java412
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java193
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpFib.java227
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddPeerCommand.java96
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddSpeakerCommand.java90
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/PrimaryChangeCommand.java40
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemovePeerCommand.java81
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemoveSpeakerCommand.java87
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/package-info.java20
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/package-info.java20
-rw-r--r--framework/src/onos/apps/sdnip/src/main/resources/OSGI-INF/blueprint/shell-config.xml35
-rw-r--r--framework/src/onos/apps/sdnip/src/main/resources/config-examples/README5
-rw-r--r--framework/src/onos/apps/sdnip/src/main/resources/config-examples/sdnip.json86
-rw-r--r--framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java421
-rw-r--r--framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java557
-rw-r--r--framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpFibTest.java417
-rw-r--r--framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java91
21 files changed, 0 insertions, 3256 deletions
diff --git a/framework/src/onos/apps/sdnip/app.xml b/framework/src/onos/apps/sdnip/app.xml
deleted file mode 100644
index 7aafa6ab..00000000
--- a/framework/src/onos/apps/sdnip/app.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<app name="org.onosproject.sdnip" origin="ON.Lab" version="${project.version}"
- featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
- features="${project.artifactId}">
- <description>${project.description}</description>
- <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-app-routing-api/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-app-routing/${project.version}</artifact>
-</app>
diff --git a/framework/src/onos/apps/sdnip/features.xml b/framework/src/onos/apps/sdnip/features.xml
deleted file mode 100644
index 5bd0dbc4..00000000
--- a/framework/src/onos/apps/sdnip/features.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
- <feature name="onos-app-sdnip" version="${project.version}"
- description="${project.description}">
- <feature>onos-api</feature>
- <bundle>mvn:${project.groupId}/onos-app-sdnip/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-app-routing-api/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-app-routing/${project.version}</bundle>
- </feature>
-</features>
diff --git a/framework/src/onos/apps/sdnip/pom.xml b/framework/src/onos/apps/sdnip/pom.xml
deleted file mode 100644
index 8ff8cbcf..00000000
--- a/framework/src/onos/apps/sdnip/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2014 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-app-sdnip</artifactId>
- <packaging>bundle</packaging>
-
- <description>SDN-IP peering application</description>
-
- <dependencies>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-misc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-routing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
deleted file mode 100644
index 09d4a436..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.IntentUtils;
-import org.onosproject.net.intent.Key;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Synchronizes intents between the in-memory intent store and the
- * IntentService.
- */
-public class IntentSynchronizer implements IntentSynchronizationService {
-
- private static final Logger log =
- LoggerFactory.getLogger(IntentSynchronizer.class);
-
- private final ApplicationId appId;
- private final IntentService intentService;
-
- private final Map<Key, Intent> intents;
-
- //
- // State to deal with the Leader election and pushing Intents
- //
- private final ExecutorService intentsSynchronizerExecutor;
- private volatile boolean isElectedLeader = false;
- private volatile boolean isActivatedLeader = false;
-
- /**
- * Class constructor.
- *
- * @param appId the Application ID
- * @param intentService the intent service
- */
- public IntentSynchronizer(ApplicationId appId, IntentService intentService) {
- this(appId, intentService,
- newSingleThreadExecutor(groupedThreads("onos/" + appId, "sync")));
- }
-
- /**
- * Class constructor.
- *
- * @param appId the Application ID
- * @param intentService the intent service
- * @param executorService executor service for synchronization thread
- */
- public IntentSynchronizer(ApplicationId appId, IntentService intentService,
- ExecutorService executorService) {
- this.appId = appId;
- this.intentService = intentService;
-
- intents = new ConcurrentHashMap<>();
-
- intentsSynchronizerExecutor = executorService;
- }
-
- /**
- * Starts the synchronizer.
- */
- public void start() {
-
- }
-
- /**
- * Stops the synchronizer.
- */
- public void stop() {
- synchronized (this) {
- // Stop the thread(s)
- intentsSynchronizerExecutor.shutdownNow();
- log.info("Intents Synchronizer Executor shutdown completed");
-
- }
- }
-
- /**
- * Withdraws all intents.
- */
- public void removeIntents() {
- if (!isElectedLeader) {
- // only leader will withdraw intents
- return;
- }
-
- log.debug("Intent Synchronizer shutdown: withdrawing all intents...");
-
- for (Entry<Key, Intent> entry : intents.entrySet()) {
- intentService.withdraw(entry.getValue());
- log.debug("Intent Synchronizer withdrawing intent: {}",
- entry.getValue());
- }
-
- intents.clear();
- log.info("Tried to clean all intents");
- }
-
- @Override
- public void submit(Intent intent) {
- synchronized (this) {
- intents.put(intent.key(), intent);
- if (isElectedLeader && isActivatedLeader) {
- log.trace("Submitting intent: {}", intent);
- intentService.submit(intent);
- }
- }
- }
-
- @Override
- public void withdraw(Intent intent) {
- synchronized (this) {
- intents.remove(intent.key(), intent);
- if (isElectedLeader && isActivatedLeader) {
- log.trace("Withdrawing intent: {}", intent);
- intentService.withdraw(intent);
- }
- }
- }
-
- /**
- * Signals the synchronizer that the leadership has changed.
- *
- * @param isLeader true if this instance is now the leader, otherwise false
- */
- public void leaderChanged(boolean isLeader) {
- log.debug("Leader changed: {}", isLeader);
-
- if (!isLeader) {
- this.isElectedLeader = false;
- this.isActivatedLeader = false;
- return; // Nothing to do
- }
- this.isActivatedLeader = false;
- this.isElectedLeader = true;
-
- // Run the synchronization method off-thread
- intentsSynchronizerExecutor.execute(this::synchronizeIntents);
- }
-
- private void synchronizeIntents() {
- Map<Key, Intent> serviceIntents = new HashMap<>();
- intentService.getIntents().forEach(i -> {
- if (i.appId().equals(appId)) {
- serviceIntents.put(i.key(), i);
- }
- });
-
- List<Intent> intentsToAdd = new LinkedList<>();
- List<Intent> intentsToRemove = new LinkedList<>();
-
- for (Intent localIntent : intents.values()) {
- Intent serviceIntent = serviceIntents.remove(localIntent.key());
- if (serviceIntent == null) {
- intentsToAdd.add(localIntent);
- } else {
- IntentState state = intentService.getIntentState(serviceIntent.key());
- if (!IntentUtils.equals(serviceIntent, localIntent) || state == null ||
- state == IntentState.WITHDRAW_REQ ||
- state == IntentState.WITHDRAWING ||
- state == IntentState.WITHDRAWN) {
- intentsToAdd.add(localIntent);
- }
- }
- }
-
- for (Intent serviceIntent : serviceIntents.values()) {
- IntentState state = intentService.getIntentState(serviceIntent.key());
- if (state != null && state != IntentState.WITHDRAW_REQ
- && state != IntentState.WITHDRAWING
- && state != IntentState.WITHDRAWN) {
- intentsToRemove.add(serviceIntent);
- }
- }
-
- log.debug("Intent Synchronizer: submitting {}, withdrawing {}",
- intentsToAdd.size(), intentsToRemove.size());
-
- // Withdraw Intents
- for (Intent intent : intentsToRemove) {
- intentService.withdraw(intent);
- log.trace("Intent Synchronizer: withdrawing intent: {}",
- intent);
- }
- if (!isElectedLeader) {
- log.debug("Intent Synchronizer: cannot withdraw intents: " +
- "not elected leader anymore");
- isActivatedLeader = false;
- return;
- }
-
- // Add Intents
- for (Intent intent : intentsToAdd) {
- intentService.submit(intent);
- log.trace("Intent Synchronizer: submitting intent: {}",
- intent);
- }
- if (!isElectedLeader) {
- log.debug("Intent Synchronizer: cannot submit intents: " +
- "not elected leader anymore");
- isActivatedLeader = false;
- return;
- }
-
- if (isElectedLeader) {
- isActivatedLeader = true; // Allow push of Intents
- } else {
- isActivatedLeader = false;
- }
- log.debug("Intent synchronization completed");
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
deleted file mode 100644
index edc2df4d..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IPv6;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.TpPort;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.intent.IntentUtils;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PointToPointIntent;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Manages the connectivity requirements between peers.
- */
-public class PeerConnectivityManager {
- private static final int PRIORITY_OFFSET = 1000;
-
- private static final String SUFFIX_DST = "dst";
- private static final String SUFFIX_SRC = "src";
- private static final String SUFFIX_ICMP = "icmp";
-
- private static final Logger log = LoggerFactory.getLogger(
- PeerConnectivityManager.class);
-
- private static final short BGP_PORT = 179;
-
- private final IntentSynchronizationService intentSynchronizer;
- private final NetworkConfigService configService;
- private final InterfaceService interfaceService;
-
- private final ApplicationId appId;
- private final ApplicationId routerAppId;
-
- private final Map<Key, PointToPointIntent> peerIntents;
-
- private final InternalNetworkConfigListener configListener
- = new InternalNetworkConfigListener();
-
- /**
- * Creates a new PeerConnectivityManager.
- *
- * @param appId the application ID
- * @param intentSynchronizer the intent synchronizer
- * @param configService the SDN-IP config service
- * @param interfaceService the interface service
- * @param routerAppId application ID
- */
- public PeerConnectivityManager(ApplicationId appId,
- IntentSynchronizationService intentSynchronizer,
- NetworkConfigService configService,
- ApplicationId routerAppId,
- InterfaceService interfaceService) {
- this.appId = appId;
- this.intentSynchronizer = intentSynchronizer;
- this.configService = configService;
- this.routerAppId = routerAppId;
- this.interfaceService = interfaceService;
-
- peerIntents = new HashMap<>();
- }
-
- /**
- * Starts the peer connectivity manager.
- */
- public void start() {
- configService.addListener(configListener);
- setUpConnectivity();
- }
-
- /**
- * Stops the peer connectivity manager.
- */
- public void stop() {
- configService.removeListener(configListener);
- }
-
- /**
- * Sets up paths to establish connectivity between all internal
- * BGP speakers and external BGP peers.
- */
- private void setUpConnectivity() {
- BgpConfig config = configService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
-
- if (config == null) {
- log.warn("No BgpConfig found");
- return;
- }
-
- Map<Key, PointToPointIntent> existingIntents = new HashMap<>(peerIntents);
-
- for (BgpConfig.BgpSpeakerConfig bgpSpeaker : config.bgpSpeakers()) {
- log.debug("Start to set up BGP paths for BGP speaker: {}",
- bgpSpeaker);
-
- buildSpeakerIntents(bgpSpeaker).forEach(i -> {
- PointToPointIntent intent = existingIntents.remove(i.key());
- if (intent == null || !IntentUtils.equals(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);
- });
- }
-
- private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker) {
- List<PointToPointIntent> intents = new ArrayList<>();
-
- 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 peeringAddress = null;
- for (InterfaceIpAddress address : peeringInterface.ipAddresses()) {
- if (address.subnetAddress().contains(peerAddress)) {
- peeringAddress = address.ipAddress();
- break;
- }
- }
-
- checkNotNull(peeringAddress);
-
- intents.addAll(buildIntents(speaker.connectPoint(), peeringAddress,
- peeringInterface.connectPoint(), peerAddress));
- }
-
- return intents;
- }
-
- /**
- * 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 destination TCP port 179
- selector = buildSelector(tcpProtocol,
- ipOne,
- ipTwo,
- null,
- BGP_PORT);
-
- key = buildKey(ipOne, ipTwo, SUFFIX_DST);
-
- intents.add(PointToPointIntent.builder()
- .appId(appId)
- .key(key)
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(portOne)
- .egressPoint(portTwo)
- .priority(PRIORITY_OFFSET)
- .build());
-
- // 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)
- .ingressPoint(portOne)
- .egressPoint(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)
- .ingressPoint(portTwo)
- .egressPoint(portOne)
- .priority(PRIORITY_OFFSET)
- .build());
-
- // Path from BGP peer to BGP speaker matching source TCP port 179
- selector = buildSelector(tcpProtocol,
- ipTwo,
- ipOne,
- BGP_PORT,
- null);
-
- key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
-
- intents.add(PointToPointIntent.builder()
- .appId(appId)
- .key(key)
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(portTwo)
- .egressPoint(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)
- .ingressPoint(portOne)
- .egressPoint(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)
- .ingressPoint(portTwo)
- .egressPoint(portOne)
- .priority(PRIORITY_OFFSET)
- .build());
-
- return intents;
- }
-
- /**
- * Builds a traffic selector based on the set of input parameters.
- *
- * @param ipProto IP protocol
- * @param srcIp source IP address
- * @param dstIp destination IP address
- * @param srcTcpPort source TCP port, or null if shouldn't be set
- * @param dstTcpPort destination TCP port, or null if shouldn't be set
- * @return the new traffic selector
- */
- private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
- IpAddress dstIp, Short srcTcpPort,
- Short dstTcpPort) {
- TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);
-
- if (dstIp.isIp4()) {
- builder.matchEthType(Ethernet.TYPE_IPV4)
- .matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
- .matchIPDst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET_MASK_LENGTH));
- } else {
- builder.matchEthType(Ethernet.TYPE_IPV6)
- .matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
- .matchIPv6Dst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET6_MASK_LENGTH));
- }
-
- if (srcTcpPort != null) {
- builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
- }
-
- if (dstTcpPort != null) {
- builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
- }
-
- return builder.build();
- }
-
- /**
- * Builds an intent Key for a point-to-point intent based off the source
- * and destination IP address, as well as a suffix String to distinguish
- * between different types of intents between the same source and
- * destination.
- *
- * @param srcIp source IP address
- * @param dstIp destination IP address
- * @param suffix suffix string
- * @return intent key
- */
- private Key buildKey(IpAddress srcIp, IpAddress dstIp, String suffix) {
- String keyString = new StringBuilder()
- .append(srcIp.toString())
- .append("-")
- .append(dstIp.toString())
- .append("-")
- .append(suffix)
- .toString();
-
- return Key.of(keyString, appId);
- }
-
- private class InternalNetworkConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- switch (event.type()) {
- case CONFIG_REGISTERED:
- break;
- case CONFIG_UNREGISTERED:
- break;
- case CONFIG_ADDED:
- case CONFIG_UPDATED:
- case CONFIG_REMOVED:
- if (event.configClass() == RoutingService.CONFIG_CLASS) {
- setUpConnectivity();
- }
- break;
- default:
- break;
- }
- }
- }
-
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
deleted file mode 100644
index ace888d1..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Objects;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.app.ApplicationService;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.cluster.LeadershipEvent;
-import org.onosproject.cluster.LeadershipEventListener;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.SdnIpService;
-import org.onosproject.routing.config.RoutingConfigurationService;
-import org.slf4j.Logger;
-
-/**
- * Component for the SDN-IP peering application.
- */
-@Component(immediate = true)
-@Service
-public class SdnIp implements SdnIpService {
-
- private static final String SDN_IP_APP = "org.onosproject.sdnip";
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected IntentService intentService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ApplicationService applicationService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RoutingService routingService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RoutingConfigurationService config;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigService networkConfigService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected InterfaceService interfaceService;
-
- private IntentSynchronizer intentSynchronizer;
- private PeerConnectivityManager peerConnectivity;
- private SdnIpFib fib;
-
- private LeadershipEventListener leadershipEventListener =
- new InnerLeadershipEventListener();
- private ApplicationId appId;
- private ControllerNode localControllerNode;
-
- @Activate
- protected void activate() {
- log.info("SDN-IP started");
-
- appId = coreService.registerApplication(SDN_IP_APP);
-
- localControllerNode = clusterService.getLocalNode();
-
- intentSynchronizer = new IntentSynchronizer(appId, intentService);
- intentSynchronizer.start();
-
- peerConnectivity = new PeerConnectivityManager(appId,
- intentSynchronizer,
- networkConfigService,
- coreService.getAppId(RoutingService.ROUTER_APP_ID),
- interfaceService);
- peerConnectivity.start();
-
- fib = new SdnIpFib(appId, interfaceService, intentSynchronizer);
-
- routingService.addFibListener(fib);
- routingService.start();
-
- leadershipService.addListener(leadershipEventListener);
- leadershipService.runForLeadership(appId.name());
-
- applicationService.registerDeactivateHook(appId,
- intentSynchronizer::removeIntents);
-
- }
-
- @Deactivate
- protected void deactivate() {
- routingService.stop();
- peerConnectivity.stop();
- intentSynchronizer.stop();
-
- leadershipService.withdraw(appId.name());
- leadershipService.removeListener(leadershipEventListener);
-
- log.info("SDN-IP Stopped");
- }
-
- @Override
- public void modifyPrimary(boolean isPrimary) {
- intentSynchronizer.leaderChanged(isPrimary);
- }
-
- @Override
- public IntentSynchronizationService getIntentSynchronizationService() {
- return intentSynchronizer;
- }
-
- /**
- * Converts DPIDs of the form xx:xx:xx:xx:xx:xx:xx to OpenFlow provider
- * device URIs.
- *
- * @param dpid the DPID string to convert
- * @return the URI string for this device
- */
- static String dpidToUri(String dpid) {
- return "of:" + dpid.replace(":", "");
- }
-
- /**
- * A listener for Leadership Events.
- */
- private class InnerLeadershipEventListener
- implements LeadershipEventListener {
-
- @Override
- public void event(LeadershipEvent event) {
- log.debug("Leadership Event: time = {} type = {} event = {}",
- event.time(), event.type(), event);
-
- if (!event.subject().topic().equals(appId.name())) {
- return; // Not our topic: ignore
- }
- if (!Objects.equals(event.subject().leader(), localControllerNode.id())) {
- return; // The event is not about this instance: ignore
- }
-
- switch (event.type()) {
- case LEADER_ELECTED:
- log.info("SDN-IP Leader Elected");
- intentSynchronizer.leaderChanged(true);
- break;
- case LEADER_BOOTED:
- log.info("SDN-IP Leader Lost Election");
- intentSynchronizer.leaderChanged(false);
- break;
- case LEADER_REELECTED:
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpFib.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpFib.java
deleted file mode 100644
index 9113e013..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpFib.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip;
-
-import com.google.common.collect.ImmutableList;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.net.intent.constraint.PartialFailureConstraint;
-import org.onosproject.routing.FibListener;
-import org.onosproject.routing.FibUpdate;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * FIB component of SDN-IP.
- */
-public class SdnIpFib implements FibListener {
- private Logger log = LoggerFactory.getLogger(getClass());
-
- private static final int PRIORITY_OFFSET = 100;
- private static final int PRIORITY_MULTIPLIER = 5;
- protected static final ImmutableList<Constraint> CONSTRAINTS
- = ImmutableList.of(new PartialFailureConstraint());
-
- private final Map<IpPrefix, MultiPointToSinglePointIntent> routeIntents;
-
- private final ApplicationId appId;
- private final InterfaceService interfaceService;
- private final IntentSynchronizationService intentSynchronizer;
-
- /**
- * Class constructor.
- *
- * @param appId application ID to use when generating intents
- * @param interfaceService interface service
- * @param intentSynchronizer intent synchronizer
- */
- public SdnIpFib(ApplicationId appId, InterfaceService interfaceService,
- IntentSynchronizationService intentSynchronizer) {
- routeIntents = new ConcurrentHashMap<>();
-
- this.appId = appId;
- this.interfaceService = interfaceService;
- this.intentSynchronizer = intentSynchronizer;
- }
-
-
- @Override
- public void update(Collection<FibUpdate> updates,
- Collection<FibUpdate> withdraws) {
- int submitCount = 0, withdrawCount = 0;
- //
- // NOTE: Semantically, we MUST withdraw existing intents before
- // submitting new intents.
- //
- synchronized (this) {
- MultiPointToSinglePointIntent intent;
-
- //
- // Prepare the Intent batch operations for the intents to withdraw
- //
- for (FibUpdate withdraw : withdraws) {
- checkArgument(withdraw.type() == FibUpdate.Type.DELETE,
- "FibUpdate with wrong type in withdraws list");
-
- IpPrefix prefix = withdraw.entry().prefix();
- intent = routeIntents.remove(prefix);
- if (intent == null) {
- log.trace("SDN-IP No intent in routeIntents to delete " +
- "for prefix: {}", prefix);
- continue;
- }
- intentSynchronizer.withdraw(intent);
- withdrawCount++;
- }
-
- //
- // Prepare the Intent batch operations for the intents to submit
- //
- for (FibUpdate update : updates) {
- checkArgument(update.type() == FibUpdate.Type.UPDATE,
- "FibUpdate with wrong type in updates list");
-
- IpPrefix prefix = update.entry().prefix();
- intent = generateRouteIntent(prefix, update.entry().nextHopIp(),
- update.entry().nextHopMac());
-
- if (intent == null) {
- // This preserves the old semantics - if an intent can't be
- // generated, we don't do anything with that prefix. But
- // perhaps we should withdraw the old intent anyway?
- continue;
- }
-
- routeIntents.put(prefix, intent);
- intentSynchronizer.submit(intent);
- submitCount++;
- }
-
- log.debug("SDN-IP submitted {}/{}, withdrew = {}/{}", submitCount,
- updates.size(), withdrawCount, withdraws.size());
- }
- }
-
- /**
- * Generates a route intent for a prefix, the next hop IP address, and
- * the next hop MAC address.
- * <p/>
- * This method will find the egress interface for the intent.
- * Intent will match dst IP prefix and rewrite dst MAC address at all other
- * border switches, then forward packets according to dst MAC address.
- *
- * @param prefix IP prefix of the route to add
- * @param nextHopIpAddress IP address of the next hop
- * @param nextHopMacAddress MAC address of the next hop
- * @return the generated intent, or null if no intent should be submitted
- */
- private MultiPointToSinglePointIntent generateRouteIntent(
- IpPrefix prefix,
- IpAddress nextHopIpAddress,
- MacAddress nextHopMacAddress) {
-
- // Find the attachment point (egress interface) of the next hop
- Interface egressInterface =
- interfaceService.getMatchingInterface(nextHopIpAddress);
- if (egressInterface == null) {
- log.warn("No outgoing interface found for {}",
- nextHopIpAddress);
- return null;
- }
-
- // Generate the intent itself
- Set<ConnectPoint> ingressPorts = new HashSet<>();
- ConnectPoint egressPort = egressInterface.connectPoint();
- log.debug("Generating intent for prefix {}, next hop mac {}",
- prefix, nextHopMacAddress);
-
- for (Interface intf : interfaceService.getInterfaces()) {
- // TODO this should be only peering interfaces
- if (!intf.connectPoint().equals(egressInterface.connectPoint())) {
- ConnectPoint srcPort = intf.connectPoint();
- ingressPorts.add(srcPort);
- }
- }
-
- // Match the destination IP prefix at the first hop
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- if (prefix.isIp4()) {
- selector.matchEthType(Ethernet.TYPE_IPV4);
- // if it is default route, then we do not need match destination
- // IP address
- if (prefix.prefixLength() != 0) {
- selector.matchIPDst(prefix);
- }
- } else {
- selector.matchEthType(Ethernet.TYPE_IPV6);
- // if it is default route, then we do not need match destination
- // IP address
- if (prefix.prefixLength() != 0) {
- selector.matchIPv6Dst(prefix);
- }
-
- }
-
- // Rewrite the destination MAC address
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
- .setEthDst(nextHopMacAddress);
- if (!egressInterface.vlan().equals(VlanId.NONE)) {
- treatment.setVlanId(egressInterface.vlan());
- // If we set VLAN ID, we have to make sure a VLAN tag exists.
- // TODO support no VLAN -> VLAN routing
- selector.matchVlanId(VlanId.ANY);
- }
-
- int priority =
- prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
- Key key = Key.of(prefix.toString(), appId);
- return MultiPointToSinglePointIntent.builder()
- .appId(appId)
- .key(key)
- .selector(selector.build())
- .treatment(treatment.build())
- .ingressPoints(ingressPorts)
- .egressPoint(egressPort)
- .priority(priority)
- .constraints(CONSTRAINTS)
- .build();
- }
-
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddPeerCommand.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddPeerCommand.java
deleted file mode 100644
index 81231ab9..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddPeerCommand.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
-
-/**
- * Command to add new BGP peer to existing internal speaker.
- */
-@Command(scope = "onos", name = "add-bgp-peer",
- description = "Adds an external BGP router as peer to an existing BGP speaker")
-public class AddPeerCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "name",
- description = "Name of the internal BGP speaker",
- required = true, multiValued = false)
- String name = null;
-
- @Argument(index = 1, name = "ip",
- description = "IP address of the BGP peer",
- required = true, multiValued = false)
- String ip = null;
-
- private static final String PEER_ADD_SUCCESS = "Peer Successfully Added.";
- private static final String NO_CONFIGURATION = "No speakers configured";
- private static final String SPEAKER_NOT_FOUND =
- "Speaker with name \'%s\' not found";
- private static final String NO_INTERFACE =
- "No matching interface found for IP \'%s\'";
-
- private IpAddress peerAddress = null;
-
- @Override
- protected void execute() {
- peerAddress = IpAddress.valueOf(ip);
-
- NetworkConfigService configService = get(NetworkConfigService.class);
- CoreService coreService = get(CoreService.class);
- ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
-
- BgpConfig config = configService.getConfig(appId, BgpConfig.class);
- if (config == null || config.bgpSpeakers().isEmpty()) {
- print(NO_CONFIGURATION);
- return;
- }
-
- BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
- if (speaker == null) {
- print(SPEAKER_NOT_FOUND, name);
- return;
- } else {
- if (speaker.isConnectedToPeer(peerAddress)) {
- return; // Peering already exists.
- }
- }
-
- InterfaceService interfaceService = get(InterfaceService.class);
- if (interfaceService.getMatchingInterface(peerAddress) == null) {
- print(NO_INTERFACE, ip);
- return;
- }
-
- addPeerToSpeakerConf(config);
- configService.applyConfig(appId, BgpConfig.class, config.node());
-
- print(PEER_ADD_SUCCESS);
- }
-
- private void addPeerToSpeakerConf(BgpConfig config) {
- log.debug("Creating BGP configuration for new peer: {}", ip);
- config.addPeerToSpeaker(name, peerAddress);
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddSpeakerCommand.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddSpeakerCommand.java
deleted file mode 100644
index 84353852..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/AddSpeakerCommand.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
-
-import java.util.HashSet;
-import java.util.Optional;
-
-/**
- * Command to add a new internal BGP speaker.
- */
-@Command(scope = "onos", name = "add-bgp-speaker",
- description = "Adds an internal BGP speaker")
-public class AddSpeakerCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "name",
- description = "Name of the internal BGP speaker",
- required = true, multiValued = false)
- String name = null;
-
- @Argument(index = 1, name = "connectionPoint",
- description = "Interface to the BGP speaker",
- required = true, multiValued = false)
- String connectionPoint = null;
-
- private static final String SPEAKER_ADD_SUCCESS = "Speaker Successfully Added.";
-
- @Override
- protected void execute() {
- NetworkConfigService configService = get(NetworkConfigService.class);
- CoreService coreService = get(CoreService.class);
- ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
-
- BgpConfig config = configService.addConfig(appId, BgpConfig.class);
-
- BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
- if (speaker != null) {
- log.debug("Speaker already exists: {}", name);
- return;
- }
-
- addSpeakerToConf(config);
- configService.applyConfig(appId, BgpConfig.class, config.node());
-
- print(SPEAKER_ADD_SUCCESS);
- }
-
- /**
- * Adds the speaker to the BgpConfig service.
- *
- * @param config the BGP configuration
- */
- private void addSpeakerToConf(BgpConfig config) {
- log.debug("Adding new speaker to configuration: {}", name);
- BgpConfig.BgpSpeakerConfig speaker = getSpeaker();
-
- config.addSpeaker(speaker);
- }
-
- private BgpConfig.BgpSpeakerConfig getSpeaker() {
- ConnectPoint connectPoint = ConnectPoint.
- deviceConnectPoint(connectionPoint);
- return new BgpConfig.BgpSpeakerConfig(Optional.ofNullable(name),
- connectPoint, new HashSet<IpAddress>());
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/PrimaryChangeCommand.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/PrimaryChangeCommand.java
deleted file mode 100644
index 7a17cfe0..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/PrimaryChangeCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.routing.SdnIpService;
-
-/**
- * Command to change whether this SDNIP instance is primary or not.
- */
-@Command(scope = "onos", name = "sdnip-set-primary",
- description = "Changes the primary status of this SDN-IP instance")
-public class PrimaryChangeCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "isPrimary",
- description = "True if this instance should be primary, false if not",
- required = true, multiValued = false)
- boolean isPrimary = false;
-
- @Override
- protected void execute() {
- get(SdnIpService.class).modifyPrimary(isPrimary);
- }
-
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemovePeerCommand.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemovePeerCommand.java
deleted file mode 100644
index bfc6fb7b..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemovePeerCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
-
-/**
- * Command to remove existing BGP peer.
- */
-@Command(scope = "onos", name = "remove-bgp-peer",
- description = "Removes a BGP peer")
-public class RemovePeerCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "ip",
- description = "IP address of the BGP peer",
- required = true, multiValued = false)
- String ip = null;
-
- private static final String PEER_REMOVE_SUCCESS = "Peer Successfully Removed.";
- private static final String NO_CONFIGURATION = "No speakers configured";
- private static final String PEER_NOT_FOUND =
- "Peer with IP \'%s\' not found";
-
- private IpAddress peerAddress = null;
-
- @Override
- protected void execute() {
- peerAddress = IpAddress.valueOf(ip);
-
- NetworkConfigService configService = get(NetworkConfigService.class);
- CoreService coreService = get(CoreService.class);
- ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
-
- BgpConfig config = configService.getConfig(appId, BgpConfig.class);
- if (config == null || config.bgpSpeakers().isEmpty()) {
- print(NO_CONFIGURATION);
- return;
- }
-
- peerAddress = IpAddress.valueOf(ip);
-
- BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerFromPeer(peerAddress);
- if (speaker == null) {
- print(PEER_NOT_FOUND, ip);
- return;
- }
-
- removePeerFromSpeakerConf(speaker, config);
- configService.applyConfig(appId, BgpConfig.class, config.node());
-
- print(PEER_REMOVE_SUCCESS);
- }
-
- private void removePeerFromSpeakerConf(BgpConfig.BgpSpeakerConfig speaker,
- BgpConfig config) {
- log.debug("Removing BGP configuration for peer: {}", ip);
- config.removePeerFromSpeaker(speaker, peerAddress);
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemoveSpeakerCommand.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemoveSpeakerCommand.java
deleted file mode 100644
index 6a51b42f..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/RemoveSpeakerCommand.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
-
-/**
- * Command to remove a internal BGP speaker.
- */
-@Command(scope = "onos", name = "remove-bgp-speaker",
- description = "Removes an internal BGP speaker")
-public class RemoveSpeakerCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "name",
- description = "Name of the internal BGP speaker",
- required = true, multiValued = false)
- String name = null;
-
- private static final String SPEAKER_REMOVE_SUCCESS = "Speaker Successfully Removed.";
- private static final String NO_CONFIGURATION = "No speakers configured";
- private static final String PEERS_EXIST =
- "Speaker with name \'%s\' has peer connections";
- private static final String SPEAKER_NOT_FOUND =
- "Speaker with name \'%s\' not found";
-
- @Override
- protected void execute() {
- NetworkConfigService configService = get(NetworkConfigService.class);
- CoreService coreService = get(CoreService.class);
- ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
-
- BgpConfig config = configService.getConfig(appId, BgpConfig.class);
- if (config == null || config.bgpSpeakers().isEmpty()) {
- print(NO_CONFIGURATION);
- return;
- }
-
- BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
- if (speaker == null) {
- print(SPEAKER_NOT_FOUND, name);
- return;
- } else {
- if (!speaker.peers().isEmpty()) {
- // Removal not allowed when peer connections exist.
- print(PEERS_EXIST, name);
- return;
- }
- }
-
- removeSpeakerFromConf(config);
- configService.applyConfig(appId, BgpConfig.class, config.node());
-
- print(SPEAKER_REMOVE_SUCCESS);
- }
-
- /**
- * Removes the speaker from the BgpConfig service.
- *
- * @param bgpConfig the BGP configuration
- */
- private void removeSpeakerFromConf(BgpConfig bgpConfig) {
- log.debug("Removing speaker from configuration: {}", name);
-
- bgpConfig.removeSpeaker(name);
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/package-info.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/package-info.java
deleted file mode 100644
index 73ea2a4f..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * SDN-IP command-line handlers.
- */
-package org.onosproject.sdnip.cli;
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/package-info.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/package-info.java
deleted file mode 100644
index 1e7d8cb9..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * SDN-IP peering application.
- */
-package org.onosproject.sdnip;
diff --git a/framework/src/onos/apps/sdnip/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/apps/sdnip/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index 97b2f09f..00000000
--- a/framework/src/onos/apps/sdnip/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- ~ Copyright 2014 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.onosproject.sdnip.cli.PrimaryChangeCommand"/>
- </command>
- <command>
- <action class="org.onosproject.sdnip.cli.AddSpeakerCommand"/>
- </command>
- <command>
- <action class="org.onosproject.sdnip.cli.RemoveSpeakerCommand"/>
- </command>
- <command>
- <action class="org.onosproject.sdnip.cli.AddPeerCommand"/>
- </command>
- <command>
- <action class="org.onosproject.sdnip.cli.RemovePeerCommand"/>
- </command>
- </command-bundle>
-</blueprint>
diff --git a/framework/src/onos/apps/sdnip/src/main/resources/config-examples/README b/framework/src/onos/apps/sdnip/src/main/resources/config-examples/README
deleted file mode 100644
index 7642a4dd..00000000
--- a/framework/src/onos/apps/sdnip/src/main/resources/config-examples/README
+++ /dev/null
@@ -1,5 +0,0 @@
-The SDN-IP configuration files should be copied to directory
- $ONOS_HOME/tools/package/config
-
-After deployment and starting up the ONOS cluster, ONOS looks for these
-configuration files in /opt/onos/config on each cluster member.
diff --git a/framework/src/onos/apps/sdnip/src/main/resources/config-examples/sdnip.json b/framework/src/onos/apps/sdnip/src/main/resources/config-examples/sdnip.json
deleted file mode 100644
index c51de68a..00000000
--- a/framework/src/onos/apps/sdnip/src/main/resources/config-examples/sdnip.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "bgpPeers" : [
- {
- "attachmentDpid" : "00:00:00:00:00:00:00:a3",
- "attachmentPort" : "1",
- "ipAddress" : "192.168.10.1"
- },
- {
- "attachmentDpid" : "00:00:00:00:00:00:00:a5",
- "attachmentPort" : "1",
- "ipAddress" : "192.168.20.1"
- },
- {
- "attachmentDpid" : "00:00:00:00:00:00:00:a2",
- "attachmentPort" : "1",
- "ipAddress" : "192.168.30.1"
- },
- {
- "attachmentDpid" : "00:00:00:00:00:00:00:a6",
- "attachmentPort" : "1",
- "ipAddress" : "192.168.40.1"
- },
- {
- "attachmentDpid" : "00:00:00:00:00:00:00:a4",
- "attachmentPort" : "4",
- "ipAddress" : "192.168.60.1"
- }
- ],
- "bgpSpeakers" : [
- {
- "name" : "bgpSpeaker1",
- "attachmentDpid" : "00:00:00:00:00:00:00:a1",
- "attachmentPort" : "1",
- "macAddress" : "00:00:00:00:00:01",
- "interfaceAddresses" : [
- {
- "interfaceDpid" : "00:00:00:00:00:00:00:a3",
- "interfacePort" : "1",
- "ipAddress" : "192.168.10.101"
- },
- {
- "interfaceDpid" : "00:00:00:00:00:00:00:a5",
- "interfacePort" : "1",
- "ipAddress" : "192.168.20.101"
- },
- {
- "interfaceDpid" : "00:00:00:00:00:00:00:a2",
- "interfacePort" : "1",
- "ipAddress" : "192.168.30.101"
- },
- {
- "interfaceDpid" : "00:00:00:00:00:00:00:a6",
- "interfacePort" : "1",
- "ipAddress" : "192.168.40.101"
- },
- {
- "interfaceDpid" : "00:00:00:00:00:00:00:a4",
- "interfacePort" : "4",
- "ipAddress" : "192.168.60.101"
- }
-
- ]
-
- }
- ],
- "ip4LocalPrefixes" : [
- {
- "ipPrefix" : "100.0.0.0/24",
- "type" : "PUBLIC",
- "gatewayIp" : "100.0.0.1"
- },
- {
- "ipPrefix" : "200.0.0.0/8",
- "type" : "PUBLIC",
- "gatewayIp" : "200.0.0.3"
- },
- {
- "ipPrefix" : "192.0.0.0/24",
- "type" : "PRIVATE",
- "gatewayIp" : "192.0.0.254"
- }
- ],
- "ip6LocalPrefixes" : [
- ],
- "virtualGatewayMacAddress" : "00:00:00:00:00:01"
-}
diff --git a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java b/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
deleted file mode 100644
index 4736aa1d..00000000
--- a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.junit.TestUtils;
-import org.onlab.junit.TestUtils.TestUtilsException;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.TestApplicationId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.intent.AbstractIntentTest;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.net.intent.IntentUtils;
-import org.onosproject.routing.RouteEntry;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-
-/**
- * This class tests the intent synchronization function in the
- * IntentSynchronizer class.
- */
-public class IntentSyncTest extends AbstractIntentTest {
-
- private IntentService intentService;
-
- private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000001"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000002"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000003"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW4_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000004"),
- PortNumber.portNumber(1));
-
- private IntentSynchronizer intentSynchronizer;
- private final Set<Interface> interfaces = Sets.newHashSet();
-
- private static final ApplicationId APPID = TestApplicationId.create("SDNIP");
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- setUpInterfaceService();
-
- intentService = createMock(IntentService.class);
-
- intentSynchronizer = new IntentSynchronizer(APPID, intentService,
- MoreExecutors.newDirectExecutorService());
- }
-
- /**
- * Sets up InterfaceService.
- */
- private void setUpInterfaceService() {
- Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
- interfaceIpAddresses1.add(new InterfaceIpAddress(
- IpAddress.valueOf("192.168.10.101"),
- IpPrefix.valueOf("192.168.10.0/24")));
- Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
- interfaces.add(sw1Eth1);
-
- Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
- interfaceIpAddresses2.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"),
- IpPrefix.valueOf("192.168.20.0/24")));
- Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.NONE);
- interfaces.add(sw2Eth1);
-
- Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
- interfaceIpAddresses3.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"),
- IpPrefix.valueOf("192.168.30.0/24")));
- Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
- interfaces.add(sw3Eth1);
-
- InterfaceIpAddress interfaceIpAddress4 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"),
- IpPrefix.valueOf("192.168.40.0/24"));
- Interface sw4Eth1 = new Interface(SW4_ETH1,
- Sets.newHashSet(interfaceIpAddress4),
- MacAddress.valueOf("00:00:00:00:00:04"),
- VlanId.vlanId((short) 1));
-
- interfaces.add(sw4Eth1);
- }
-
- /**
- * Tests the synchronization behavior of intent synchronizer. We set up
- * a discrepancy between the intent service state and the intent
- * synchronizer's state and ensure that this is reconciled correctly.
- *
- * @throws TestUtilsException
- */
- @Test
- public void testIntentSync() throws TestUtilsException {
-
- //
- // Construct routes and intents.
- // This test simulates the following cases during the master change
- // time interval:
- // 1. RouteEntry1 did not change and the intent also did not change.
- // 2. RouteEntry2 was deleted, but the intent was not deleted.
- // 3. RouteEntry3 was newly added, and the intent was also submitted.
- // 4. RouteEntry4 was updated to RouteEntry4Update, and the intent was
- // also updated to a new one.
- // 5. RouteEntry5 did not change, but its intent id changed.
- // 6. RouteEntry6 was newly added, but the intent was not submitted.
- //
- RouteEntry routeEntry1 = new RouteEntry(
- Ip4Prefix.valueOf("1.1.1.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry2 = new RouteEntry(
- Ip4Prefix.valueOf("2.2.2.0/24"),
- Ip4Address.valueOf("192.168.20.1"));
-
- RouteEntry routeEntry3 = new RouteEntry(
- Ip4Prefix.valueOf("3.3.3.0/24"),
- Ip4Address.valueOf("192.168.30.1"));
-
- RouteEntry routeEntry4 = new RouteEntry(
- Ip4Prefix.valueOf("4.4.4.0/24"),
- Ip4Address.valueOf("192.168.30.1"));
-
- RouteEntry routeEntry4Update = new RouteEntry(
- Ip4Prefix.valueOf("4.4.4.0/24"),
- Ip4Address.valueOf("192.168.20.1"));
-
- RouteEntry routeEntry5 = new RouteEntry(
- Ip4Prefix.valueOf("5.5.5.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry6 = new RouteEntry(
- Ip4Prefix.valueOf("6.6.6.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- RouteEntry routeEntry7 = new RouteEntry(
- Ip4Prefix.valueOf("7.7.7.0/24"),
- Ip4Address.valueOf("192.168.10.1"));
-
- MultiPointToSinglePointIntent intent1 = intentBuilder(
- routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
- MultiPointToSinglePointIntent intent2 = intentBuilder(
- routeEntry2.prefix(), "00:00:00:00:00:02", SW2_ETH1);
- MultiPointToSinglePointIntent intent3 = intentBuilder(
- routeEntry3.prefix(), "00:00:00:00:00:03", SW3_ETH1);
- MultiPointToSinglePointIntent intent4 = intentBuilder(
- routeEntry4.prefix(), "00:00:00:00:00:03", SW3_ETH1);
- MultiPointToSinglePointIntent intent4Update = intentBuilder(
- routeEntry4Update.prefix(), "00:00:00:00:00:02", SW2_ETH1);
- MultiPointToSinglePointIntent intent5 = intentBuilder(
- routeEntry5.prefix(), "00:00:00:00:00:01", SW1_ETH1);
- MultiPointToSinglePointIntent intent7 = intentBuilder(
- routeEntry7.prefix(), "00:00:00:00:00:01", SW1_ETH1);
-
- // Compose a intent, which is equal to intent5 but the id is different.
- MultiPointToSinglePointIntent intent5New =
- staticIntentBuilder(intent5, routeEntry5, "00:00:00:00:00:01");
- assertThat(IntentUtils.equals(intent5, intent5New), is(true));
- assertFalse(intent5.equals(intent5New));
-
- MultiPointToSinglePointIntent intent6 = intentBuilder(
- routeEntry6.prefix(), "00:00:00:00:00:01", SW1_ETH1);
-
- // Set up expectation
- Set<Intent> intents = new HashSet<>();
- intents.add(intent1);
- expect(intentService.getIntentState(intent1.key()))
- .andReturn(IntentState.INSTALLED).anyTimes();
- intents.add(intent2);
- expect(intentService.getIntentState(intent2.key()))
- .andReturn(IntentState.INSTALLED).anyTimes();
- intents.add(intent4);
- expect(intentService.getIntentState(intent4.key()))
- .andReturn(IntentState.INSTALLED).anyTimes();
- intents.add(intent5);
- expect(intentService.getIntentState(intent5.key()))
- .andReturn(IntentState.INSTALLED).anyTimes();
- intents.add(intent7);
- expect(intentService.getIntentState(intent7.key()))
- .andReturn(IntentState.WITHDRAWING).anyTimes();
- expect(intentService.getIntents()).andReturn(intents).anyTimes();
-
- // These are the operations that should be done to the intentService
- // during synchronization
- intentService.withdraw(intent2);
- intentService.submit(intent3);
- intentService.submit(intent4Update);
- intentService.submit(intent6);
- intentService.submit(intent7);
- replay(intentService);
-
- // Start the test
-
- // Simulate some input from the clients. The intent synchronizer has not
- // gained the global leadership yet, but it will remember this input for
- // when it does.
- intentSynchronizer.submit(intent1);
- intentSynchronizer.submit(intent2);
- intentSynchronizer.withdraw(intent2);
- intentSynchronizer.submit(intent3);
- intentSynchronizer.submit(intent4);
- intentSynchronizer.submit(intent4Update);
- intentSynchronizer.submit(intent5);
- intentSynchronizer.submit(intent6);
- intentSynchronizer.submit(intent7);
-
- // Give the leadership to the intent synchronizer. It will now attempt
- // to synchronize the intents in the store with the intents it has
- // recorded based on the earlier user input.
- intentSynchronizer.leaderChanged(true);
-
- verify(intentService);
- }
-
- /**
- * Tests the behavior of the submit API, both when the synchronizer has
- * leadership and when it does not.
- */
- @Test
- public void testSubmit() {
- IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
- Intent intent = intentBuilder(prefix, "00:00:00:00:00:01", SW1_ETH1);
-
- // Set up expectations
- intentService.submit(intent);
- expect(intentService.getIntents()).andReturn(Collections.emptyList())
- .anyTimes();
- replay(intentService);
-
- // Give the intent synchronizer leadership so it will submit intents
- // to the intent service
- intentSynchronizer.leaderChanged(true);
-
- // Test the submit
- intentSynchronizer.submit(intent);
-
- verify(intentService);
-
- // Now we'll remove leadership from the intent synchronizer and verify
- // that it does not submit any intents to the intent service when we
- // call the submit API
- reset(intentService);
- replay(intentService);
-
- intentSynchronizer.leaderChanged(false);
-
- intentSynchronizer.submit(intent);
-
- verify(intentService);
- }
-
- /**
- * Tests the behavior of the withdraw API, both when the synchronizer has
- * leadership and when it does not.
- */
- @Test
- public void testWithdraw() {
- IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
- Intent intent = intentBuilder(prefix, "00:00:00:00:00:01", SW1_ETH1);
-
- // Submit an intent first so we can withdraw it later
- intentService.submit(intent);
- intentService.withdraw(intent);
- expect(intentService.getIntents()).andReturn(Collections.emptyList())
- .anyTimes();
- replay(intentService);
-
- // Give the intent synchronizer leadership so it will submit intents
- // to the intent service
- intentSynchronizer.leaderChanged(true);
-
- // Test the submit then withdraw
- intentSynchronizer.submit(intent);
- intentSynchronizer.withdraw(intent);
-
- verify(intentService);
-
- // Now we'll remove leadership from the intent synchronizer and verify
- // that it does not withdraw any intents to the intent service when we
- // call the withdraw API
- reset(intentService);
- replay(intentService);
-
- intentSynchronizer.leaderChanged(false);
-
- intentSynchronizer.submit(intent);
- intentSynchronizer.withdraw(intent);
-
- verify(intentService);
- }
-
- /**
- * MultiPointToSinglePointIntent builder.
- *
- * @param ipPrefix the ipPrefix to match
- * @param nextHopMacAddress to which the destination MAC address in packet
- * should be rewritten
- * @param egressPoint to which packets should be sent
- * @return the constructed MultiPointToSinglePointIntent
- */
- private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix,
- String nextHopMacAddress, ConnectPoint egressPoint) {
-
- TrafficSelector.Builder selectorBuilder =
- DefaultTrafficSelector.builder();
- if (ipPrefix.isIp4()) {
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
- selectorBuilder.matchIPDst(ipPrefix);
- } else {
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV6);
- selectorBuilder.matchIPv6Dst(ipPrefix);
- }
-
- TrafficTreatment.Builder treatmentBuilder =
- DefaultTrafficTreatment.builder();
- treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress));
-
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- for (Interface intf : interfaces) {
- if (!intf.connectPoint().equals(egressPoint)) {
- ConnectPoint srcPort = intf.connectPoint();
- ingressPoints.add(srcPort);
- }
- }
- MultiPointToSinglePointIntent intent =
- MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .key(Key.of(ipPrefix.toString(), APPID))
- .selector(selectorBuilder.build())
- .treatment(treatmentBuilder.build())
- .ingressPoints(ingressPoints)
- .egressPoint(egressPoint)
- .constraints(SdnIpFib.CONSTRAINTS)
- .build();
- return intent;
- }
-
- /**
- * A static MultiPointToSinglePointIntent builder, the returned intent is
- * equal to the input intent except that the id is different.
- *
- * @param intent the intent to be used for building a new intent
- * @param routeEntry the relative routeEntry of the intent
- * @return the newly constructed MultiPointToSinglePointIntent
- * @throws TestUtilsException
- */
- private MultiPointToSinglePointIntent staticIntentBuilder(
- MultiPointToSinglePointIntent intent, RouteEntry routeEntry,
- String nextHopMacAddress) throws TestUtilsException {
-
- // Use a different egress ConnectPoint with that in intent
- // to generate a different id
- MultiPointToSinglePointIntent intentNew = intentBuilder(
- routeEntry.prefix(), nextHopMacAddress, SW2_ETH1);
- TestUtils.setField(intentNew, "egressPoint", intent.egressPoint());
- TestUtils.setField(intentNew,
- "ingressPoints", intent.ingressPoints());
- return intentNew;
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java b/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
deleted file mode 100644
index 0dcc969d..00000000
--- a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/PeerConnectivityManagerTest.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import com.google.common.collect.Sets;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onlab.junit.TestUtils.TestUtilsException;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TpPort;
-import org.onlab.packet.VlanId;
-import org.onosproject.TestApplicationId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.intent.AbstractIntentTest;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PointToPointIntent;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.config.BgpConfig;
-import org.onosproject.routing.config.BgpPeer;
-import org.onosproject.routing.config.BgpSpeaker;
-import org.onosproject.routing.config.InterfaceAddress;
-import org.onosproject.routing.config.RoutingConfigurationService;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
-
-/**
- * Unit tests for PeerConnectivityManager.
- */
-public class PeerConnectivityManagerTest extends AbstractIntentTest {
-
- private static final ApplicationId APPID = TestApplicationId.create("foo");
-
- private static final ApplicationId CONFIG_APP_ID = APPID;
-
- private PeerConnectivityManager peerConnectivityManager;
- private IntentSynchronizationService intentSynchronizer;
- private RoutingConfigurationService routingConfig;
- private InterfaceService interfaceService;
- private NetworkConfigService networkConfigService;
-
- private Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers;
- private Map<String, Interface> interfaces;
- private Map<IpAddress, BgpPeer> peers;
-
- private BgpConfig bgpConfig;
-
- private List<PointToPointIntent> intentList;
-
- private final String dpid1 = "00:00:00:00:00:00:00:01";
- private final String dpid2 = "00:00:00:00:00:00:00:02";
-
- private final DeviceId deviceId1 =
- DeviceId.deviceId(SdnIp.dpidToUri(dpid1));
- private final DeviceId deviceId2 =
- DeviceId.deviceId(SdnIp.dpidToUri(dpid2));
-
- // Interfaces connected to BGP speakers
- private final ConnectPoint s1Eth100 =
- new ConnectPoint(deviceId1, PortNumber.portNumber(100));
- private final ConnectPoint s2Eth100 =
- new ConnectPoint(deviceId2, PortNumber.portNumber(100));
-
- // Interfaces connected to BGP peers
- private final ConnectPoint s1Eth1 =
- new ConnectPoint(deviceId1, PortNumber.portNumber(1));
- private final ConnectPoint s2Eth1 =
- new ConnectPoint(deviceId2, PortNumber.portNumber(1));
-
- private final TrafficTreatment noTreatment =
- DefaultTrafficTreatment.emptyTreatment();
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- routingConfig = createMock(RoutingConfigurationService.class);
- interfaceService = createMock(InterfaceService.class);
- networkConfigService = createMock(NetworkConfigService.class);
- networkConfigService.addListener(anyObject(NetworkConfigListener.class));
- expectLastCall().anyTimes();
- bgpConfig = createMock(BgpConfig.class);
-
- // These will set expectations on routingConfig and interfaceService
- bgpSpeakers = setUpBgpSpeakers();
- interfaces = Collections.unmodifiableMap(setUpInterfaces());
- peers = setUpPeers();
-
- initPeerConnectivity();
- intentList = setUpIntentList();
- }
-
- /**
- * Sets up BGP speakers.
- *
- * @return configured BGP speakers as a map from speaker name to speaker
- */
- private Set<BgpConfig.BgpSpeakerConfig> setUpBgpSpeakers() {
-
- BgpConfig.BgpSpeakerConfig speaker1 = new BgpConfig.BgpSpeakerConfig(
- Optional.empty(),
- s1Eth100, Collections.singleton(IpAddress.valueOf("192.168.10.1")));
-
- BgpConfig.BgpSpeakerConfig speaker2 = new BgpConfig.BgpSpeakerConfig(
- Optional.empty(),
- s1Eth100, Sets.newHashSet(IpAddress.valueOf("192.168.20.1"),
- IpAddress.valueOf("192.168.30.1")));
-
- Set<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Sets.newHashSet();
- bgpSpeakers.add(speaker1);
- bgpSpeakers.add(speaker2);
-
- return bgpSpeakers;
- }
-
- /**
- * Sets up logical interfaces, which emulate the configured interfaces
- * in SDN-IP application.
- *
- * @return configured interfaces as a map from interface name to Interface
- */
- private Map<String, Interface> setUpInterfaces() {
-
- Map<String, Interface> configuredInterfaces = new HashMap<>();
-
- String interfaceSw1Eth1 = "s1-eth1";
- InterfaceIpAddress ia1 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.10.101"),
- IpPrefix.valueOf("192.168.10.0/24"));
- Interface intfsw1eth1 = new Interface(s1Eth1,
- Collections.singleton(ia1),
- MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
-
- configuredInterfaces.put(interfaceSw1Eth1, intfsw1eth1);
- String interfaceSw2Eth1 = "s2-eth1";
- InterfaceIpAddress ia2 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"),
- IpPrefix.valueOf("192.168.20.0/24"));
- Interface intfsw2eth1 = new Interface(s2Eth1,
- Collections.singleton(ia2),
- MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.NONE);
- configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1);
-
- String interfaceSw2Eth1intf2 = "s2-eth1_2";
- InterfaceIpAddress ia3 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"),
- IpPrefix.valueOf("192.168.30.0/24"));
- Interface intfsw2eth1intf2 = new Interface(s2Eth1,
- Collections.singleton(ia3),
- MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
- configuredInterfaces.put(interfaceSw2Eth1intf2, intfsw2eth1intf2);
-
- expect(interfaceService.getInterfacesByPort(s1Eth1))
- .andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101")))
- .andReturn(Collections.singleton(intfsw1eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1")))
- .andReturn(intfsw1eth1).anyTimes();
- expect(interfaceService.getInterfacesByPort(s2Eth1))
- .andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101")))
- .andReturn(Collections.singleton(intfsw2eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1")))
- .andReturn(intfsw2eth1).anyTimes();
-
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101")))
- .andReturn(Collections.singleton(intfsw2eth1intf2)).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1")))
- .andReturn(intfsw2eth1intf2).anyTimes();
-
- // Non-existent interface used during one of the tests
- expect(interfaceService.getInterfacesByPort(new ConnectPoint(
- DeviceId.deviceId(SdnIp.dpidToUri("00:00:00:00:00:00:01:00")),
- PortNumber.portNumber(1))))
- .andReturn(null).anyTimes();
-
- expect(interfaceService.getInterfaces()).andReturn(
- Sets.newHashSet(configuredInterfaces.values())).anyTimes();
-
- return configuredInterfaces;
- }
-
- /**
- * Sets up BGP daemon peers.
- *
- * @return configured BGP peers as a MAP from peer IP address to BgpPeer
- */
- private Map<IpAddress, BgpPeer> setUpPeers() {
-
- Map<IpAddress, BgpPeer> configuredPeers = new HashMap<>();
-
- String peerSw1Eth1 = "192.168.10.1";
- configuredPeers.put(IpAddress.valueOf(peerSw1Eth1),
- new BgpPeer(dpid1, 1, peerSw1Eth1));
-
- // Two BGP peers are connected to switch 2 port 1.
- String peer1Sw2Eth1 = "192.168.20.1";
- configuredPeers.put(IpAddress.valueOf(peer1Sw2Eth1),
- new BgpPeer(dpid2, 1, peer1Sw2Eth1));
-
- String peer2Sw2Eth1 = "192.168.30.1";
- configuredPeers.put(IpAddress.valueOf(peer2Sw2Eth1),
- new BgpPeer(dpid2, 1, peer2Sw2Eth1));
-
- return configuredPeers;
- }
-
- /**
- * Sets up expected point to point intent list.
- *
- * @return point to point intent list
- */
- private List<PointToPointIntent> setUpIntentList() {
- intentList = new ArrayList<>();
-
- setUpBgpIntents();
- setUpIcmpIntents();
-
- return intentList;
- }
-
- /**
- * 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 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(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 (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(noTreatment)
- .ingressPoint(srcConnectPoint)
- .egressPoint(dstConnectPoint)
- .build();
-
- intentList.add(intent);
- }
-
- /**
- * Sets up intents for BGP paths.
- */
- private void setUpBgpIntents() {
-
- Short bgpPort = 179;
-
- // Start to build intents between BGP speaker1 and BGP peer1
- bgpPathintentConstructor(
- "192.168.10.101/32", "192.168.10.1/32", null, bgpPort,
- s1Eth100, s1Eth1);
- bgpPathintentConstructor(
- "192.168.10.101/32", "192.168.10.1/32", bgpPort, null,
- s1Eth100, s1Eth1);
-
- bgpPathintentConstructor(
- "192.168.10.1/32", "192.168.10.101/32", null, bgpPort,
- s1Eth1, s1Eth100);
- bgpPathintentConstructor(
- "192.168.10.1/32", "192.168.10.101/32", bgpPort, null,
- s1Eth1, s1Eth100);
-
- // Start to build intents between BGP speaker1 and BGP peer2
- bgpPathintentConstructor(
- "192.168.20.101/32", "192.168.20.1/32", null, bgpPort,
- s1Eth100, s2Eth1);
- bgpPathintentConstructor(
- "192.168.20.101/32", "192.168.20.1/32", bgpPort, null,
- s1Eth100, s2Eth1);
-
- bgpPathintentConstructor(
- "192.168.20.1/32", "192.168.20.101/32", null, bgpPort,
- s2Eth1, s1Eth100);
- bgpPathintentConstructor(
- "192.168.20.1/32", "192.168.20.101/32", bgpPort, null,
- s2Eth1, s1Eth100);
-
- //
- // Start to build intents between BGP speaker3 and BGP peer1
- bgpPathintentConstructor(
- "192.168.30.101/32", "192.168.30.1/32", null, bgpPort,
- s1Eth100, s2Eth1);
- bgpPathintentConstructor(
- "192.168.30.101/32", "192.168.30.1/32", bgpPort, null,
- s1Eth100, s2Eth1);
-
- bgpPathintentConstructor(
- "192.168.30.1/32", "192.168.30.101/32", null, bgpPort,
- s2Eth1, s1Eth100);
- bgpPathintentConstructor(
- "192.168.30.1/32", "192.168.30.101/32", bgpPort, null,
- s2Eth1, s1Eth100);
- }
-
- /**
- * 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 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(String srcPrefix, String dstPrefix,
- ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) {
-
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchIPProtocol(IPv4.PROTOCOL_ICMP)
- .matchIPSrc(IpPrefix.valueOf(srcPrefix))
- .matchIPDst(IpPrefix.valueOf(dstPrefix))
- .build();
-
- Key key = Key.of(srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0]
- + "-" + "icmp", APPID);
-
- PointToPointIntent intent = PointToPointIntent.builder()
- .appId(APPID)
- .key(key)
- .selector(selector)
- .treatment(noTreatment)
- .ingressPoint(srcConnectPoint)
- .egressPoint(dstConnectPoint)
- .build();
-
- intentList.add(intent);
- }
-
- /**
- * Sets up intents for ICMP paths.
- */
- private void setUpIcmpIntents() {
- // Start to build intents between BGP speaker1 and BGP peer1
- icmpPathintentConstructor(
- "192.168.10.101/32", "192.168.10.1/32", s1Eth100, s1Eth1);
- icmpPathintentConstructor(
- "192.168.10.1/32", "192.168.10.101/32", s1Eth1, s1Eth100);
-
- // Start to build intents between BGP speaker1 and BGP peer2
- icmpPathintentConstructor(
- "192.168.20.101/32", "192.168.20.1/32", s1Eth100, s2Eth1);
- icmpPathintentConstructor(
- "192.168.20.1/32", "192.168.20.101/32", s2Eth1, s1Eth100);
-
- icmpPathintentConstructor(
- "192.168.30.101/32", "192.168.30.1/32", s1Eth100, s2Eth1);
- icmpPathintentConstructor(
- "192.168.30.1/32", "192.168.30.101/32", s2Eth1, s1Eth100);
- }
-
- /**
- * Initializes peer connectivity testing environment.
- *
- * @throws TestUtilsException if exceptions when using TestUtils
- */
- private void initPeerConnectivity() throws TestUtilsException {
- expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes();
- expect(bgpConfig.bgpSpeakers()).andReturn(bgpSpeakers).anyTimes();
- replay(bgpConfig);
- expect(networkConfigService.getConfig(APPID, BgpConfig.class))
- .andReturn(bgpConfig).anyTimes();
- replay(networkConfigService);
- replay(routingConfig);
- replay(interfaceService);
-
- intentSynchronizer = createMock(IntentSynchronizationService.class);
- replay(intentSynchronizer);
-
- peerConnectivityManager =
- new PeerConnectivityManager(APPID, intentSynchronizer,
- networkConfigService,
- CONFIG_APP_ID,
- interfaceService);
- }
-
- /**
- * Tests whether peer connectivity manager can set up correct BGP and
- * ICMP intents according to specific configuration.
- * <p/>
- * Two tricky cases included in the configuration are: 2 peers on a same
- * switch port, peer on the same switch with BGPd.
- */
- @Test
- public void testConnectionSetup() {
- reset(intentSynchronizer);
-
- // Setup the expected intents
- for (Intent intent : intentList) {
- intentSynchronizer.submit(eqExceptId(intent));
- }
- replay(intentSynchronizer);
-
- // Running the interface to be tested.
- peerConnectivityManager.start();
-
- verify(intentSynchronizer);
- }
-
- /**
- * Tests a corner case, when there are no interfaces in the configuration.
- */
- @Test
- public void testNullInterfaces() {
- reset(interfaceService);
-
- expect(interfaceService.getInterfaces()).andReturn(
- Sets.newHashSet()).anyTimes();
- expect(interfaceService.getInterfacesByPort(s2Eth1))
- .andReturn(Collections.emptySet()).anyTimes();
- expect(interfaceService.getInterfacesByPort(s1Eth1))
- .andReturn(Collections.emptySet()).anyTimes();
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.10.101")))
- .andReturn(Collections.emptySet()).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.10.1")))
- .andReturn(null).anyTimes();
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.20.101")))
- .andReturn(Collections.emptySet()).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.20.1")))
- .andReturn(null).anyTimes();
- expect(interfaceService.getInterfacesByIp(IpAddress.valueOf("192.168.30.101")))
- .andReturn(Collections.emptySet()).anyTimes();
- expect(interfaceService.getMatchingInterface(IpAddress.valueOf("192.168.30.1")))
- .andReturn(null).anyTimes();
-
- replay(interfaceService);
-
- reset(intentSynchronizer);
- replay(intentSynchronizer);
- peerConnectivityManager.start();
- verify(intentSynchronizer);
- }
-
- /**
- * Tests a corner case, when there is no BGP speakers in the configuration.
- */
- @Test
- public void testNullBgpSpeakers() {
- reset(routingConfig);
- reset(bgpConfig);
-
- expect(bgpConfig.bgpSpeakers()).andReturn(Collections.emptySet()).anyTimes();
- replay(bgpConfig);
- expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes();
- replay(routingConfig);
-
- reset(intentSynchronizer);
- replay(intentSynchronizer);
- peerConnectivityManager.start();
- verify(intentSynchronizer);
- }
-
- /**
- * Tests a corner case, when there is no Interface configured for one BGP
- * peer.
- */
- @Test
- public void testNoPeerInterface() {
- String peerSw100Eth1 = "192.168.200.1";
- peers.put(IpAddress.valueOf(peerSw100Eth1),
- new BgpPeer("00:00:00:00:00:00:01:00", 1, peerSw100Eth1));
- testConnectionSetup();
- }
-
- /**
- * Tests a corner case, when there is no Interface configured for one BGP
- * speaker.
- */
- @Ignore
- @Test
- public void testNoSpeakerInterface() {
- BgpSpeaker bgpSpeaker100 = new BgpSpeaker(
- "bgpSpeaker100",
- "00:00:00:00:00:00:01:00", 100,
- "00:00:00:00:01:00");
- List<InterfaceAddress> interfaceAddresses100 = new LinkedList<>();
- interfaceAddresses100.add(new InterfaceAddress(dpid1, 1, "192.168.10.201"));
- interfaceAddresses100.add(new InterfaceAddress(dpid2, 1, "192.168.20.201"));
- bgpSpeaker100.setInterfaceAddresses(interfaceAddresses100);
- testConnectionSetup();
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpFibTest.java b/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpFibTest.java
deleted file mode 100644
index 5466d520..00000000
--- a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/SdnIpFibTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdnip;
-
-import com.google.common.collect.Sets;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.TestApplicationId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.intent.AbstractIntentTest;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.routing.FibEntry;
-import org.onosproject.routing.FibUpdate;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.config.BgpPeer;
-import org.onosproject.routing.config.RoutingConfigurationService;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId;
-
-/**
- * Unit tests for SdnIpFib.
- */
-public class SdnIpFibTest extends AbstractIntentTest {
-
- private RoutingConfigurationService routingConfig;
- private InterfaceService interfaceService;
-
- private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000001"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW2_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000002"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW3_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000003"),
- PortNumber.portNumber(1));
-
- private static final ConnectPoint SW4_ETH1 = new ConnectPoint(
- DeviceId.deviceId("of:0000000000000004"),
- PortNumber.portNumber(1));
-
- private SdnIpFib sdnipFib;
- private IntentSynchronizationService intentSynchronizer;
- private final Set<Interface> interfaces = Sets.newHashSet();
-
- private static final ApplicationId APPID = TestApplicationId.create("SDNIP");
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- routingConfig = createMock(RoutingConfigurationService.class);
- interfaceService = createMock(InterfaceService.class);
-
- // These will set expectations on routingConfig and interfaceService
- setUpInterfaceService();
- setUpBgpPeers();
-
- replay(routingConfig);
- replay(interfaceService);
-
- intentSynchronizer = createMock(IntentSynchronizationService.class);
-
- sdnipFib = new SdnIpFib(APPID, interfaceService, intentSynchronizer);
- }
-
- /**
- * Sets up BGP peers in external networks.
- */
- private void setUpBgpPeers() {
-
- Map<IpAddress, BgpPeer> peers = new HashMap<>();
-
- String peerSw1Eth1 = "192.168.10.1";
- peers.put(IpAddress.valueOf(peerSw1Eth1),
- new BgpPeer("00:00:00:00:00:00:00:01", 1, peerSw1Eth1));
-
- // Two BGP peers are connected to switch 2 port 1.
- String peer1Sw2Eth1 = "192.168.20.1";
- peers.put(IpAddress.valueOf(peer1Sw2Eth1),
- new BgpPeer("00:00:00:00:00:00:00:02", 1, peer1Sw2Eth1));
-
- String peer2Sw2Eth1 = "192.168.20.2";
- peers.put(IpAddress.valueOf(peer2Sw2Eth1),
- new BgpPeer("00:00:00:00:00:00:00:02", 1, peer2Sw2Eth1));
-
- String peer1Sw4Eth1 = "192.168.40.1";
- peers.put(IpAddress.valueOf(peer1Sw4Eth1),
- new BgpPeer("00:00:00:00:00:00:00:04", 1, peer1Sw4Eth1));
-
- expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes();
- }
-
- /**
- * Sets up InterfaceService.
- */
- private void setUpInterfaceService() {
- Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet();
- interfaceIpAddresses1.add(new InterfaceIpAddress(
- IpAddress.valueOf("192.168.10.101"),
- IpPrefix.valueOf("192.168.10.0/24")));
- Interface sw1Eth1 = new Interface(SW1_ETH1,
- interfaceIpAddresses1, MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
- interfaces.add(sw1Eth1);
-
- Set<InterfaceIpAddress> interfaceIpAddresses2 = Sets.newHashSet();
- interfaceIpAddresses2.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.20.101"),
- IpPrefix.valueOf("192.168.20.0/24")));
- Interface sw2Eth1 = new Interface(SW2_ETH1,
- interfaceIpAddresses2, MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.NONE);
- interfaces.add(sw2Eth1);
-
- Set<InterfaceIpAddress> interfaceIpAddresses3 = Sets.newHashSet();
- interfaceIpAddresses3.add(
- new InterfaceIpAddress(IpAddress.valueOf("192.168.30.101"),
- IpPrefix.valueOf("192.168.30.0/24")));
- Interface sw3Eth1 = new Interface(SW3_ETH1,
- interfaceIpAddresses3, MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
- interfaces.add(sw3Eth1);
-
- InterfaceIpAddress interfaceIpAddress4 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"),
- IpPrefix.valueOf("192.168.40.0/24"));
- Interface sw4Eth1 = new Interface(SW4_ETH1,
- Sets.newHashSet(interfaceIpAddress4),
- MacAddress.valueOf("00:00:00:00:00:04"),
- VlanId.vlanId((short) 1));
-
- expect(interfaceService.getInterfacesByPort(SW4_ETH1)).andReturn(
- Collections.singleton(sw4Eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.40.1")))
- .andReturn(sw4Eth1).anyTimes();
-
- interfaces.add(sw4Eth1);
-
- expect(interfaceService.getInterfacesByPort(SW1_ETH1)).andReturn(
- Collections.singleton(sw1Eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.10.1")))
- .andReturn(sw1Eth1).anyTimes();
- expect(interfaceService.getInterfacesByPort(SW2_ETH1)).andReturn(
- Collections.singleton(sw2Eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.20.1")))
- .andReturn(sw2Eth1).anyTimes();
- expect(interfaceService.getInterfacesByPort(SW3_ETH1)).andReturn(
- Collections.singleton(sw3Eth1)).anyTimes();
- expect(interfaceService.getMatchingInterface(Ip4Address.valueOf("192.168.30.1")))
- .andReturn(sw3Eth1).anyTimes();
- expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes();
- }
-
- /**
- * Tests adding a FIB entry to the IntentSynchronizer.
- *
- * We verify that the synchronizer records the correct state and that the
- * correct intent is submitted to the IntentService.
- */
- @Test
- public void testFibAdd() {
- IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
- FibEntry fibEntry = new FibEntry(prefix,
- Ip4Address.valueOf("192.168.10.1"),
- MacAddress.valueOf("00:00:00:00:00:01"));
-
- // Construct a MultiPointToSinglePointIntent intent
- TrafficSelector.Builder selectorBuilder =
- DefaultTrafficSelector.builder();
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(
- fibEntry.prefix());
-
- TrafficTreatment.Builder treatmentBuilder =
- DefaultTrafficTreatment.builder();
- treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
-
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- ingressPoints.add(SW2_ETH1);
- ingressPoints.add(SW3_ETH1);
- ingressPoints.add(SW4_ETH1);
-
- MultiPointToSinglePointIntent intent =
- MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .key(Key.of(prefix.toString(), APPID))
- .selector(selectorBuilder.build())
- .treatment(treatmentBuilder.build())
- .ingressPoints(ingressPoints)
- .egressPoint(SW1_ETH1)
- .constraints(SdnIpFib.CONSTRAINTS)
- .build();
-
- // Setup the expected intents
- intentSynchronizer.submit(eqExceptId(intent));
- replay(intentSynchronizer);
-
- // Send in the UPDATE FibUpdate
- FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry);
- sdnipFib.update(Collections.singleton(fibUpdate), Collections.emptyList());
-
- verify(intentSynchronizer);
- }
-
- /**
- * Tests adding a FIB entry with to a next hop in a VLAN.
- *
- * We verify that the synchronizer records the correct state and that the
- * correct intent is submitted to the IntentService.
- */
- @Test
- public void testFibAddWithVlan() {
- IpPrefix prefix = Ip4Prefix.valueOf("3.3.3.0/24");
- FibEntry fibEntry = new FibEntry(prefix,
- Ip4Address.valueOf("192.168.40.1"),
- MacAddress.valueOf("00:00:00:00:00:04"));
-
- // Construct a MultiPointToSinglePointIntent intent
- TrafficSelector.Builder selectorBuilder =
- DefaultTrafficSelector.builder();
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4)
- .matchIPDst(fibEntry.prefix())
- .matchVlanId(VlanId.ANY);
-
- TrafficTreatment.Builder treatmentBuilder =
- DefaultTrafficTreatment.builder();
- treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:04"))
- .setVlanId(VlanId.vlanId((short) 1));
-
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- ingressPoints.add(SW1_ETH1);
- ingressPoints.add(SW2_ETH1);
- ingressPoints.add(SW3_ETH1);
-
- MultiPointToSinglePointIntent intent =
- MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .key(Key.of(prefix.toString(), APPID))
- .selector(selectorBuilder.build())
- .treatment(treatmentBuilder.build())
- .ingressPoints(ingressPoints)
- .egressPoint(SW4_ETH1)
- .constraints(SdnIpFib.CONSTRAINTS)
- .build();
-
- // Setup the expected intents
- intentSynchronizer.submit(eqExceptId(intent));
-
- replay(intentSynchronizer);
-
- // Send in the UPDATE FibUpdate
- FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry);
- sdnipFib.update(Collections.singleton(fibUpdate), Collections.emptyList());
-
- verify(intentSynchronizer);
- }
-
- /**
- * Tests updating a FIB entry.
- *
- * We verify that the synchronizer records the correct state and that the
- * correct intent is submitted to the IntentService.
- */
- @Test
- public void testFibUpdate() {
- // Firstly add a route
- testFibAdd();
-
- IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
-
- // Start to construct a new route entry and new intent
- FibEntry fibEntryUpdate = new FibEntry(prefix,
- Ip4Address.valueOf("192.168.20.1"),
- MacAddress.valueOf("00:00:00:00:00:02"));
-
- // Construct a new MultiPointToSinglePointIntent intent
- TrafficSelector.Builder selectorBuilderNew =
- DefaultTrafficSelector.builder();
- selectorBuilderNew.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(
- fibEntryUpdate.prefix());
-
- TrafficTreatment.Builder treatmentBuilderNew =
- DefaultTrafficTreatment.builder();
- treatmentBuilderNew.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"));
-
- Set<ConnectPoint> ingressPointsNew = new HashSet<>();
- ingressPointsNew.add(SW1_ETH1);
- ingressPointsNew.add(SW3_ETH1);
- ingressPointsNew.add(SW4_ETH1);
-
- MultiPointToSinglePointIntent intentNew =
- MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .key(Key.of(prefix.toString(), APPID))
- .selector(selectorBuilderNew.build())
- .treatment(treatmentBuilderNew.build())
- .ingressPoints(ingressPointsNew)
- .egressPoint(SW2_ETH1)
- .constraints(SdnIpFib.CONSTRAINTS)
- .build();
-
- // Set up test expectation
- reset(intentSynchronizer);
-
- // Setup the expected intents
- intentSynchronizer.submit(eqExceptId(intentNew));
- replay(intentSynchronizer);
-
- // Send in the UPDATE FibUpdate
- FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE,
- fibEntryUpdate);
- sdnipFib.update(Collections.singletonList(fibUpdate),
- Collections.emptyList());
-
- verify(intentSynchronizer);
- }
-
- /**
- * Tests deleting a FIB entry.
- *
- * We verify that the synchronizer records the correct state and that the
- * correct intent is withdrawn from the IntentService.
- */
- @Test
- public void testFibDelete() {
- // Firstly add a route
- testFibAdd();
-
- IpPrefix prefix = Ip4Prefix.valueOf("1.1.1.0/24");
-
- // Construct the existing route entry
- FibEntry fibEntry = new FibEntry(prefix, null, null);
-
- // Construct the existing MultiPointToSinglePoint intent
- TrafficSelector.Builder selectorBuilder =
- DefaultTrafficSelector.builder();
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(
- fibEntry.prefix());
-
- TrafficTreatment.Builder treatmentBuilder =
- DefaultTrafficTreatment.builder();
- treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:01"));
-
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- ingressPoints.add(SW2_ETH1);
- ingressPoints.add(SW3_ETH1);
- ingressPoints.add(SW4_ETH1);
-
- MultiPointToSinglePointIntent addedIntent =
- MultiPointToSinglePointIntent.builder()
- .appId(APPID)
- .key(Key.of(prefix.toString(), APPID))
- .selector(selectorBuilder.build())
- .treatment(treatmentBuilder.build())
- .ingressPoints(ingressPoints)
- .egressPoint(SW1_ETH1)
- .constraints(SdnIpFib.CONSTRAINTS)
- .build();
-
- // Set up expectation
- reset(intentSynchronizer);
- // Setup the expected intents
- intentSynchronizer.withdraw(eqExceptId(addedIntent));
- replay(intentSynchronizer);
-
- // Send in the DELETE FibUpdate
- FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.DELETE, fibEntry);
- sdnipFib.update(Collections.emptyList(), Collections.singletonList(fibUpdate));
-
- verify(intentSynchronizer);
- }
-}
diff --git a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java b/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
deleted file mode 100644
index 4df7f9de..00000000
--- a/framework/src/onos/apps/sdnip/src/test/java/org/onosproject/sdnip/TestIntentServiceHelper.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sdnip;
-
-import org.easymock.IArgumentMatcher;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentUtils;
-
-import static org.easymock.EasyMock.reportMatcher;
-
-/**
- * Helper class for testing operations submitted to the IntentService.
- */
-public final class TestIntentServiceHelper {
- /**
- * Default constructor to prevent instantiation.
- */
- private TestIntentServiceHelper() {
- }
-
- /**
- * Matcher method to set the expected intent to match against
- * (ignoring the intent ID for the intent).
- *
- * @param intent the expected Intent
- * @return the submitted Intent
- */
- static Intent eqExceptId(Intent intent) {
- reportMatcher(new IdAgnosticIntentMatcher(intent));
- return intent;
- }
-
- /*
- * EasyMock matcher that matches {@link Intent} but
- * ignores the {@link IntentId} when matching.
- * <p/>
- * The normal intent equals method tests that the intent IDs are equal,
- * however in these tests we can't know what the intent IDs will be in
- * advance, so we can't set up expected intents with the correct IDs. Thus,
- * the solution is to use an EasyMock matcher that verifies that all the
- * value properties of the provided intent match the expected values, but
- * ignores the intent ID when testing equality.
- */
- private static final class IdAgnosticIntentMatcher implements
- IArgumentMatcher {
-
- private final Intent intent;
- private String providedString;
-
- /**
- * Constructor taking the expected intent to match against.
- *
- * @param intent the expected intent
- */
- public IdAgnosticIntentMatcher(Intent intent) {
- this.intent = intent;
- }
-
- @Override
- public void appendTo(StringBuffer strBuffer) {
- strBuffer.append("IntentMatcher unable to match: "
- + providedString);
- }
-
- @Override
- public boolean matches(Object object) {
- if (!(object instanceof Intent)) {
- return false;
- }
-
- Intent providedIntent = (Intent) object;
- providedString = providedIntent.toString();
-
- return IntentUtils.equals(intent, providedIntent);
- }
- }
-
-}