Moved routing/bgp config into common routing bundle.
This allows the configuration to be used from multiple applications. * The class that reads the configuration file is now a service so that config can be consumed by components in other bundles. * Name of config reader classes has been generalized to RoutingConfigService * All config has been added to RoutingConfigService, instead of having two service interfaces like we did previously Change-Id: Iaec9daf0f5b72abe2d6709fb75188d6d81947478
Showing
16 changed files
with
218 additions
and
210 deletions
... | @@ -13,13 +13,14 @@ | ... | @@ -13,13 +13,14 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routingapi.config; |
17 | 17 | ||
18 | import com.fasterxml.jackson.annotation.JsonProperty; | 18 | import com.fasterxml.jackson.annotation.JsonProperty; |
19 | import com.google.common.base.MoreObjects; | 19 | import com.google.common.base.MoreObjects; |
20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
22 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
23 | +import org.onosproject.net.NetTools; | ||
23 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
24 | 25 | ||
25 | import java.util.Objects; | 26 | import java.util.Objects; |
... | @@ -42,7 +43,7 @@ public class BgpPeer { | ... | @@ -42,7 +43,7 @@ public class BgpPeer { |
42 | @JsonProperty("attachmentPort") long port, | 43 | @JsonProperty("attachmentPort") long port, |
43 | @JsonProperty("ipAddress") String ipAddress) { | 44 | @JsonProperty("ipAddress") String ipAddress) { |
44 | this.connectPoint = new ConnectPoint( | 45 | this.connectPoint = new ConnectPoint( |
45 | - DeviceId.deviceId(SdnIpConfigurationReader.dpidToUri(dpid)), | 46 | + DeviceId.deviceId(NetTools.dpidToUri(dpid)), |
46 | PortNumber.portNumber(port)); | 47 | PortNumber.portNumber(port)); |
47 | this.ipAddress = IpAddress.valueOf(ipAddress); | 48 | this.ipAddress = IpAddress.valueOf(ipAddress); |
48 | } | 49 | } | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routingapi.config; |
17 | 17 | ||
18 | import com.fasterxml.jackson.annotation.JsonCreator; | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | import com.fasterxml.jackson.annotation.JsonProperty; | 19 | import com.fasterxml.jackson.annotation.JsonProperty; |
... | @@ -21,6 +21,7 @@ import com.google.common.base.MoreObjects; | ... | @@ -21,6 +21,7 @@ import com.google.common.base.MoreObjects; |
21 | import org.onlab.packet.MacAddress; | 21 | import org.onlab.packet.MacAddress; |
22 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
24 | +import org.onosproject.net.NetTools; | ||
24 | import org.onosproject.net.PortNumber; | 25 | import org.onosproject.net.PortNumber; |
25 | 26 | ||
26 | import java.util.List; | 27 | import java.util.List; |
... | @@ -63,7 +64,7 @@ public class BgpSpeaker { | ... | @@ -63,7 +64,7 @@ public class BgpSpeaker { |
63 | this.name = name; | 64 | this.name = name; |
64 | this.macAddress = MacAddress.valueOf(macAddress); | 65 | this.macAddress = MacAddress.valueOf(macAddress); |
65 | this.connectPoint = new ConnectPoint( | 66 | this.connectPoint = new ConnectPoint( |
66 | - DeviceId.deviceId(SdnIpConfigurationReader.dpidToUri(attachmentDpid)), | 67 | + DeviceId.deviceId(NetTools.dpidToUri(attachmentDpid)), |
67 | PortNumber.portNumber(attachmentPort)); | 68 | PortNumber.portNumber(attachmentPort)); |
68 | } | 69 | } |
69 | 70 | ... | ... |
... | @@ -13,19 +13,18 @@ | ... | @@ -13,19 +13,18 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routingapi.config; |
17 | - | ||
18 | -import java.util.Objects; | ||
19 | -import java.util.Set; | ||
20 | 17 | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.collect.Sets; | ||
21 | import org.onlab.packet.MacAddress; | 20 | import org.onlab.packet.MacAddress; |
22 | import org.onlab.packet.VlanId; | 21 | import org.onlab.packet.VlanId; |
23 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
24 | import org.onosproject.net.host.InterfaceIpAddress; | 23 | import org.onosproject.net.host.InterfaceIpAddress; |
25 | import org.onosproject.net.host.PortAddresses; | 24 | import org.onosproject.net.host.PortAddresses; |
26 | 25 | ||
27 | -import com.google.common.base.MoreObjects; | 26 | +import java.util.Objects; |
28 | -import com.google.common.collect.Sets; | 27 | +import java.util.Set; |
29 | 28 | ||
30 | /** | 29 | /** |
31 | * An Interface is a set of addresses that are logically mapped to a switch | 30 | * An Interface is a set of addresses that are logically mapped to a switch | ... | ... |
... | @@ -13,17 +13,17 @@ | ... | @@ -13,17 +13,17 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routingapi.config; |
17 | - | ||
18 | -import java.util.Objects; | ||
19 | 17 | ||
18 | +import com.fasterxml.jackson.annotation.JsonProperty; | ||
19 | +import com.google.common.base.MoreObjects; | ||
20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
22 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
23 | +import org.onosproject.net.NetTools; | ||
23 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
24 | 25 | ||
25 | -import com.fasterxml.jackson.annotation.JsonProperty; | 26 | +import java.util.Objects; |
26 | -import com.google.common.base.MoreObjects; | ||
27 | 27 | ||
28 | /** | 28 | /** |
29 | * Represents an address of a {@link BgpSpeaker} configured on an | 29 | * Represents an address of a {@link BgpSpeaker} configured on an |
... | @@ -48,7 +48,7 @@ public class InterfaceAddress { | ... | @@ -48,7 +48,7 @@ public class InterfaceAddress { |
48 | @JsonProperty("interfacePort") int port, | 48 | @JsonProperty("interfacePort") int port, |
49 | @JsonProperty("ipAddress") String ipAddress) { | 49 | @JsonProperty("ipAddress") String ipAddress) { |
50 | this.connectPoint = new ConnectPoint( | 50 | this.connectPoint = new ConnectPoint( |
51 | - DeviceId.deviceId(SdnIpConfigurationReader.dpidToUri(dpid)), | 51 | + DeviceId.deviceId(NetTools.dpidToUri(dpid)), |
52 | PortNumber.portNumber(port)); | 52 | PortNumber.portNumber(port)); |
53 | this.ipAddress = IpAddress.valueOf(ipAddress); | 53 | this.ipAddress = IpAddress.valueOf(ipAddress); |
54 | } | 54 | } | ... | ... |
... | @@ -13,18 +13,33 @@ | ... | @@ -13,18 +13,33 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip; | 16 | +package org.onosproject.routingapi.config; |
17 | - | ||
18 | -import java.util.Set; | ||
19 | 17 | ||
20 | import org.onlab.packet.IpAddress; | 18 | import org.onlab.packet.IpAddress; |
21 | import org.onosproject.net.ConnectPoint; | 19 | import org.onosproject.net.ConnectPoint; |
22 | -import org.onosproject.sdnip.config.Interface; | 20 | + |
21 | +import java.util.Map; | ||
22 | +import java.util.Set; | ||
23 | 23 | ||
24 | /** | 24 | /** |
25 | - * Provides information about the interfaces in the network. | 25 | + * Provides information about the routing configuration. |
26 | + */ | ||
27 | +public interface RoutingConfigurationService { | ||
28 | + | ||
29 | + /** | ||
30 | + * Gets the list of BGP speakers inside the SDN network. | ||
31 | + * | ||
32 | + * @return the map of BGP speaker names to BGP speaker objects | ||
26 | */ | 33 | */ |
27 | -public interface InterfaceService { | 34 | + public Map<String, BgpSpeaker> getBgpSpeakers(); |
35 | + | ||
36 | + /** | ||
37 | + * Gets the list of configured BGP peers. | ||
38 | + * | ||
39 | + * @return the map from peer IP address to BgpPeer object | ||
40 | + */ | ||
41 | + public Map<IpAddress, BgpPeer> getBgpPeers(); | ||
42 | + | ||
28 | /** | 43 | /** |
29 | * Retrieves the entire set of interfaces in the network. | 44 | * Retrieves the entire set of interfaces in the network. |
30 | * | 45 | * |
... | @@ -49,4 +64,5 @@ public interface InterfaceService { | ... | @@ -49,4 +64,5 @@ public interface InterfaceService { |
49 | * @return the matching interface | 64 | * @return the matching interface |
50 | */ | 65 | */ |
51 | Interface getMatchingInterface(IpAddress ipAddress); | 66 | Interface getMatchingInterface(IpAddress ipAddress); |
67 | + | ||
52 | } | 68 | } | ... | ... |
... | @@ -13,13 +13,15 @@ | ... | @@ -13,13 +13,15 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routing.config; |
17 | + | ||
18 | +import com.fasterxml.jackson.annotation.JsonProperty; | ||
19 | +import org.onosproject.routingapi.config.BgpPeer; | ||
20 | +import org.onosproject.routingapi.config.BgpSpeaker; | ||
17 | 21 | ||
18 | import java.util.Collections; | 22 | import java.util.Collections; |
19 | import java.util.List; | 23 | import java.util.List; |
20 | 24 | ||
21 | -import com.fasterxml.jackson.annotation.JsonProperty; | ||
22 | - | ||
23 | /** | 25 | /** |
24 | * Contains the configuration data for SDN-IP that has been read from a | 26 | * Contains the configuration data for SDN-IP that has been read from a |
25 | * JSON-formatted configuration file. | 27 | * JSON-formatted configuration file. | ... | ... |
... | @@ -13,25 +13,25 @@ | ... | @@ -13,25 +13,25 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip; | 16 | +package org.onosproject.routing.config; |
17 | - | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | - | ||
20 | -import java.util.Set; | ||
21 | 17 | ||
18 | +import com.google.common.collect.Sets; | ||
22 | import org.onlab.packet.IpAddress; | 19 | import org.onlab.packet.IpAddress; |
23 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
24 | import org.onosproject.net.host.HostService; | 21 | import org.onosproject.net.host.HostService; |
25 | import org.onosproject.net.host.InterfaceIpAddress; | 22 | import org.onosproject.net.host.InterfaceIpAddress; |
26 | import org.onosproject.net.host.PortAddresses; | 23 | import org.onosproject.net.host.PortAddresses; |
27 | -import org.onosproject.sdnip.config.Interface; | 24 | +import org.onosproject.routingapi.config.Interface; |
28 | 25 | ||
29 | -import com.google.common.collect.Sets; | 26 | +import java.util.Set; |
27 | + | ||
28 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
30 | 29 | ||
31 | /** | 30 | /** |
32 | - * Provides InterfaceService using PortAddresses data from the HostService. | 31 | + * Adapts PortAddresses data from the HostService into Interface data used by |
32 | + * the routing module. | ||
33 | */ | 33 | */ |
34 | -public class HostToInterfaceAdaptor implements InterfaceService { | 34 | +public class HostToInterfaceAdaptor { |
35 | 35 | ||
36 | private final HostService hostService; | 36 | private final HostService hostService; |
37 | 37 | ||
... | @@ -39,7 +39,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { | ... | @@ -39,7 +39,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { |
39 | this.hostService = checkNotNull(hostService); | 39 | this.hostService = checkNotNull(hostService); |
40 | } | 40 | } |
41 | 41 | ||
42 | - @Override | ||
43 | public Set<Interface> getInterfaces() { | 42 | public Set<Interface> getInterfaces() { |
44 | Set<PortAddresses> addresses = hostService.getAddressBindings(); | 43 | Set<PortAddresses> addresses = hostService.getAddressBindings(); |
45 | Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size()); | 44 | Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size()); |
... | @@ -49,7 +48,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { | ... | @@ -49,7 +48,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { |
49 | return interfaces; | 48 | return interfaces; |
50 | } | 49 | } |
51 | 50 | ||
52 | - @Override | ||
53 | public Interface getInterface(ConnectPoint connectPoint) { | 51 | public Interface getInterface(ConnectPoint connectPoint) { |
54 | checkNotNull(connectPoint); | 52 | checkNotNull(connectPoint); |
55 | 53 | ||
... | @@ -65,7 +63,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { | ... | @@ -65,7 +63,6 @@ public class HostToInterfaceAdaptor implements InterfaceService { |
65 | return null; | 63 | return null; |
66 | } | 64 | } |
67 | 65 | ||
68 | - @Override | ||
69 | public Interface getMatchingInterface(IpAddress ipAddress) { | 66 | public Interface getMatchingInterface(IpAddress ipAddress) { |
70 | checkNotNull(ipAddress); | 67 | checkNotNull(ipAddress); |
71 | 68 | ... | ... |
... | @@ -13,26 +13,39 @@ | ... | @@ -13,26 +13,39 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.routing.config; |
17 | + | ||
18 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
19 | +import org.apache.felix.scr.annotations.Activate; | ||
20 | +import org.apache.felix.scr.annotations.Component; | ||
21 | +import org.apache.felix.scr.annotations.Reference; | ||
22 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
23 | +import org.apache.felix.scr.annotations.Service; | ||
24 | +import org.onlab.packet.IpAddress; | ||
25 | +import org.onosproject.net.ConnectPoint; | ||
26 | +import org.onosproject.net.host.HostService; | ||
27 | +import org.onosproject.routingapi.config.BgpPeer; | ||
28 | +import org.onosproject.routingapi.config.BgpSpeaker; | ||
29 | +import org.onosproject.routingapi.config.Interface; | ||
30 | +import org.onosproject.routingapi.config.RoutingConfigurationService; | ||
31 | +import org.slf4j.Logger; | ||
32 | +import org.slf4j.LoggerFactory; | ||
17 | 33 | ||
18 | import java.io.File; | 34 | import java.io.File; |
19 | import java.io.FileNotFoundException; | 35 | import java.io.FileNotFoundException; |
20 | import java.io.IOException; | 36 | import java.io.IOException; |
21 | import java.util.Collections; | 37 | import java.util.Collections; |
22 | import java.util.Map; | 38 | import java.util.Map; |
39 | +import java.util.Set; | ||
23 | import java.util.concurrent.ConcurrentHashMap; | 40 | import java.util.concurrent.ConcurrentHashMap; |
24 | 41 | ||
25 | -import org.onlab.packet.IpAddress; | ||
26 | -import org.slf4j.Logger; | ||
27 | -import org.slf4j.LoggerFactory; | ||
28 | - | ||
29 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
30 | - | ||
31 | /** | 42 | /** |
32 | - * Implementation of SdnIpConfigurationService which reads SDN-IP configuration | 43 | + * Implementation of RoutingConfigurationService which reads routing |
33 | - * from a file. | 44 | + * configuration from a file. |
34 | */ | 45 | */ |
35 | -public class SdnIpConfigurationReader implements SdnIpConfigurationService { | 46 | +@Component(immediate = true) |
47 | +@Service | ||
48 | +public class RoutingConfigurationImpl implements RoutingConfigurationService { | ||
36 | 49 | ||
37 | private final Logger log = LoggerFactory.getLogger(getClass()); | 50 | private final Logger log = LoggerFactory.getLogger(getClass()); |
38 | 51 | ||
... | @@ -40,9 +53,21 @@ public class SdnIpConfigurationReader implements SdnIpConfigurationService { | ... | @@ -40,9 +53,21 @@ public class SdnIpConfigurationReader implements SdnIpConfigurationService { |
40 | private static final String DEFAULT_CONFIG_FILE = "sdnip.json"; | 53 | private static final String DEFAULT_CONFIG_FILE = "sdnip.json"; |
41 | private String configFileName = DEFAULT_CONFIG_FILE; | 54 | private String configFileName = DEFAULT_CONFIG_FILE; |
42 | 55 | ||
56 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
57 | + protected HostService hostService; | ||
58 | + | ||
43 | private Map<String, BgpSpeaker> bgpSpeakers = new ConcurrentHashMap<>(); | 59 | private Map<String, BgpSpeaker> bgpSpeakers = new ConcurrentHashMap<>(); |
44 | private Map<IpAddress, BgpPeer> bgpPeers = new ConcurrentHashMap<>(); | 60 | private Map<IpAddress, BgpPeer> bgpPeers = new ConcurrentHashMap<>(); |
45 | 61 | ||
62 | + private HostToInterfaceAdaptor hostAdaptor; | ||
63 | + | ||
64 | + @Activate | ||
65 | + public void activate() { | ||
66 | + readConfiguration(); | ||
67 | + hostAdaptor = new HostToInterfaceAdaptor(hostService); | ||
68 | + log.info("Routing configuration service started"); | ||
69 | + } | ||
70 | + | ||
46 | /** | 71 | /** |
47 | * Reads SDN-IP related information contained in the configuration file. | 72 | * Reads SDN-IP related information contained in the configuration file. |
48 | * | 73 | * |
... | @@ -87,14 +112,19 @@ public class SdnIpConfigurationReader implements SdnIpConfigurationService { | ... | @@ -87,14 +112,19 @@ public class SdnIpConfigurationReader implements SdnIpConfigurationService { |
87 | return Collections.unmodifiableMap(bgpPeers); | 112 | return Collections.unmodifiableMap(bgpPeers); |
88 | } | 113 | } |
89 | 114 | ||
90 | - /** | 115 | + @Override |
91 | - * Converts DPIDs of the form xx:xx:xx:xx:xx:xx:xx to OpenFlow provider | 116 | + public Set<Interface> getInterfaces() { |
92 | - * device URIs. | 117 | + return hostAdaptor.getInterfaces(); |
93 | - * | ||
94 | - * @param dpid the DPID string to convert | ||
95 | - * @return the URI string for this device | ||
96 | - */ | ||
97 | - static String dpidToUri(String dpid) { | ||
98 | - return "of:" + dpid.replace(":", ""); | ||
99 | } | 118 | } |
119 | + | ||
120 | + @Override | ||
121 | + public Interface getInterface(ConnectPoint connectPoint) { | ||
122 | + return hostAdaptor.getInterface(connectPoint); | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public Interface getMatchingInterface(IpAddress ipAddress) { | ||
127 | + return hostAdaptor.getMatchingInterface(ipAddress); | ||
128 | + } | ||
129 | + | ||
100 | } | 130 | } | ... | ... |
... | @@ -13,20 +13,10 @@ | ... | @@ -13,20 +13,10 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip; | 16 | +package org.onosproject.routing.config; |
17 | - | ||
18 | -import static org.easymock.EasyMock.createMock; | ||
19 | -import static org.easymock.EasyMock.expect; | ||
20 | -import static org.easymock.EasyMock.replay; | ||
21 | -import static org.easymock.EasyMock.reset; | ||
22 | -import static org.junit.Assert.assertEquals; | ||
23 | -import static org.junit.Assert.assertNull; | ||
24 | -import static org.junit.Assert.assertTrue; | ||
25 | - | ||
26 | -import java.util.Collections; | ||
27 | -import java.util.Map; | ||
28 | -import java.util.Set; | ||
29 | 17 | ||
18 | +import com.google.common.collect.Maps; | ||
19 | +import com.google.common.collect.Sets; | ||
30 | import org.junit.Before; | 20 | import org.junit.Before; |
31 | import org.junit.Test; | 21 | import org.junit.Test; |
32 | import org.onlab.packet.IpAddress; | 22 | import org.onlab.packet.IpAddress; |
... | @@ -39,10 +29,19 @@ import org.onosproject.net.PortNumber; | ... | @@ -39,10 +29,19 @@ import org.onosproject.net.PortNumber; |
39 | import org.onosproject.net.host.HostService; | 29 | import org.onosproject.net.host.HostService; |
40 | import org.onosproject.net.host.InterfaceIpAddress; | 30 | import org.onosproject.net.host.InterfaceIpAddress; |
41 | import org.onosproject.net.host.PortAddresses; | 31 | import org.onosproject.net.host.PortAddresses; |
42 | -import org.onosproject.sdnip.config.Interface; | 32 | +import org.onosproject.routingapi.config.Interface; |
43 | 33 | ||
44 | -import com.google.common.collect.Maps; | 34 | +import java.util.Collections; |
45 | -import com.google.common.collect.Sets; | 35 | +import java.util.Map; |
36 | +import java.util.Set; | ||
37 | + | ||
38 | +import static org.easymock.EasyMock.createMock; | ||
39 | +import static org.easymock.EasyMock.expect; | ||
40 | +import static org.easymock.EasyMock.replay; | ||
41 | +import static org.easymock.EasyMock.reset; | ||
42 | +import static org.junit.Assert.assertEquals; | ||
43 | +import static org.junit.Assert.assertNull; | ||
44 | +import static org.junit.Assert.assertTrue; | ||
46 | 45 | ||
47 | /** | 46 | /** |
48 | * Unit tests for the HostToInterfaceAdaptor class. | 47 | * Unit tests for the HostToInterfaceAdaptor class. | ... | ... |
... | @@ -37,9 +37,9 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; | ... | @@ -37,9 +37,9 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
37 | import org.onosproject.net.intent.PointToPointIntent; | 37 | import org.onosproject.net.intent.PointToPointIntent; |
38 | import org.onosproject.routingapi.FibListener; | 38 | import org.onosproject.routingapi.FibListener; |
39 | import org.onosproject.routingapi.FibUpdate; | 39 | import org.onosproject.routingapi.FibUpdate; |
40 | -import org.onosproject.sdnip.config.BgpPeer; | 40 | +import org.onosproject.routingapi.config.BgpPeer; |
41 | -import org.onosproject.sdnip.config.Interface; | 41 | +import org.onosproject.routingapi.config.Interface; |
42 | -import org.onosproject.sdnip.config.SdnIpConfigurationService; | 42 | +import org.onosproject.routingapi.config.RoutingConfigurationService; |
43 | import org.slf4j.Logger; | 43 | import org.slf4j.Logger; |
44 | import org.slf4j.LoggerFactory; | 44 | import org.slf4j.LoggerFactory; |
45 | 45 | ||
... | @@ -79,8 +79,7 @@ public class IntentSynchronizer implements FibListener { | ... | @@ -79,8 +79,7 @@ public class IntentSynchronizer implements FibListener { |
79 | private volatile boolean isElectedLeader = false; | 79 | private volatile boolean isElectedLeader = false; |
80 | private volatile boolean isActivatedLeader = false; | 80 | private volatile boolean isActivatedLeader = false; |
81 | 81 | ||
82 | - private final SdnIpConfigurationService configService; | 82 | + private final RoutingConfigurationService configService; |
83 | - private final InterfaceService interfaceService; | ||
84 | 83 | ||
85 | /** | 84 | /** |
86 | * Class constructor. | 85 | * Class constructor. |
... | @@ -88,18 +87,15 @@ public class IntentSynchronizer implements FibListener { | ... | @@ -88,18 +87,15 @@ public class IntentSynchronizer implements FibListener { |
88 | * @param appId the Application ID | 87 | * @param appId the Application ID |
89 | * @param intentService the intent service | 88 | * @param intentService the intent service |
90 | * @param configService the SDN-IP configuration service | 89 | * @param configService the SDN-IP configuration service |
91 | - * @param interfaceService the interface service | ||
92 | */ | 90 | */ |
93 | IntentSynchronizer(ApplicationId appId, IntentService intentService, | 91 | IntentSynchronizer(ApplicationId appId, IntentService intentService, |
94 | - SdnIpConfigurationService configService, | 92 | + RoutingConfigurationService configService) { |
95 | - InterfaceService interfaceService) { | ||
96 | this.appId = appId; | 93 | this.appId = appId; |
97 | this.intentService = intentService; | 94 | this.intentService = intentService; |
98 | peerIntents = new ConcurrentHashMap<>(); | 95 | peerIntents = new ConcurrentHashMap<>(); |
99 | routeIntents = new ConcurrentHashMap<>(); | 96 | routeIntents = new ConcurrentHashMap<>(); |
100 | 97 | ||
101 | this.configService = configService; | 98 | this.configService = configService; |
102 | - this.interfaceService = interfaceService; | ||
103 | 99 | ||
104 | bgpIntentsSynchronizerExecutor = Executors.newSingleThreadExecutor( | 100 | bgpIntentsSynchronizerExecutor = Executors.newSingleThreadExecutor( |
105 | new ThreadFactoryBuilder() | 101 | new ThreadFactoryBuilder() |
... | @@ -289,12 +285,12 @@ public class IntentSynchronizer implements FibListener { | ... | @@ -289,12 +285,12 @@ public class IntentSynchronizer implements FibListener { |
289 | BgpPeer peer = | 285 | BgpPeer peer = |
290 | configService.getBgpPeers().get(nextHopIpAddress); | 286 | configService.getBgpPeers().get(nextHopIpAddress); |
291 | egressInterface = | 287 | egressInterface = |
292 | - interfaceService.getInterface(peer.connectPoint()); | 288 | + configService.getInterface(peer.connectPoint()); |
293 | } else { | 289 | } else { |
294 | // Route to non-peer | 290 | // Route to non-peer |
295 | log.debug("Route to non-peer {}", nextHopIpAddress); | 291 | log.debug("Route to non-peer {}", nextHopIpAddress); |
296 | egressInterface = | 292 | egressInterface = |
297 | - interfaceService.getMatchingInterface(nextHopIpAddress); | 293 | + configService.getMatchingInterface(nextHopIpAddress); |
298 | if (egressInterface == null) { | 294 | if (egressInterface == null) { |
299 | log.warn("No outgoing interface found for {}", | 295 | log.warn("No outgoing interface found for {}", |
300 | nextHopIpAddress); | 296 | nextHopIpAddress); |
... | @@ -310,7 +306,7 @@ public class IntentSynchronizer implements FibListener { | ... | @@ -310,7 +306,7 @@ public class IntentSynchronizer implements FibListener { |
310 | log.debug("Generating intent for prefix {}, next hop mac {}", | 306 | log.debug("Generating intent for prefix {}, next hop mac {}", |
311 | prefix, nextHopMacAddress); | 307 | prefix, nextHopMacAddress); |
312 | 308 | ||
313 | - for (Interface intf : interfaceService.getInterfaces()) { | 309 | + for (Interface intf : configService.getInterfaces()) { |
314 | if (!intf.connectPoint().equals(egressInterface.connectPoint())) { | 310 | if (!intf.connectPoint().equals(egressInterface.connectPoint())) { |
315 | ConnectPoint srcPort = intf.connectPoint(); | 311 | ConnectPoint srcPort = intf.connectPoint(); |
316 | ingressPorts.add(srcPort); | 312 | ingressPorts.add(srcPort); | ... | ... |
... | @@ -28,11 +28,11 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; | ... | @@ -28,11 +28,11 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; |
28 | import org.onosproject.net.flow.TrafficSelector; | 28 | import org.onosproject.net.flow.TrafficSelector; |
29 | import org.onosproject.net.flow.TrafficTreatment; | 29 | import org.onosproject.net.flow.TrafficTreatment; |
30 | import org.onosproject.net.intent.PointToPointIntent; | 30 | import org.onosproject.net.intent.PointToPointIntent; |
31 | -import org.onosproject.sdnip.config.BgpPeer; | 31 | +import org.onosproject.routingapi.config.BgpPeer; |
32 | -import org.onosproject.sdnip.config.BgpSpeaker; | 32 | +import org.onosproject.routingapi.config.BgpSpeaker; |
33 | -import org.onosproject.sdnip.config.Interface; | 33 | +import org.onosproject.routingapi.config.Interface; |
34 | -import org.onosproject.sdnip.config.InterfaceAddress; | 34 | +import org.onosproject.routingapi.config.InterfaceAddress; |
35 | -import org.onosproject.sdnip.config.SdnIpConfigurationService; | 35 | +import org.onosproject.routingapi.config.RoutingConfigurationService; |
36 | import org.slf4j.Logger; | 36 | import org.slf4j.Logger; |
37 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
38 | 38 | ||
... | @@ -51,8 +51,7 @@ public class PeerConnectivityManager { | ... | @@ -51,8 +51,7 @@ public class PeerConnectivityManager { |
51 | private static final short BGP_PORT = 179; | 51 | private static final short BGP_PORT = 179; |
52 | 52 | ||
53 | private final IntentSynchronizer intentSynchronizer; | 53 | private final IntentSynchronizer intentSynchronizer; |
54 | - private final SdnIpConfigurationService configService; | 54 | + private final RoutingConfigurationService configService; |
55 | - private final InterfaceService interfaceService; | ||
56 | 55 | ||
57 | private final ApplicationId appId; | 56 | private final ApplicationId appId; |
58 | 57 | ||
... | @@ -62,23 +61,20 @@ public class PeerConnectivityManager { | ... | @@ -62,23 +61,20 @@ public class PeerConnectivityManager { |
62 | * @param appId the application ID | 61 | * @param appId the application ID |
63 | * @param intentSynchronizer the intent synchronizer | 62 | * @param intentSynchronizer the intent synchronizer |
64 | * @param configService the SDN-IP config service | 63 | * @param configService the SDN-IP config service |
65 | - * @param interfaceService the interface service | ||
66 | */ | 64 | */ |
67 | public PeerConnectivityManager(ApplicationId appId, | 65 | public PeerConnectivityManager(ApplicationId appId, |
68 | IntentSynchronizer intentSynchronizer, | 66 | IntentSynchronizer intentSynchronizer, |
69 | - SdnIpConfigurationService configService, | 67 | + RoutingConfigurationService configService) { |
70 | - InterfaceService interfaceService) { | ||
71 | this.appId = appId; | 68 | this.appId = appId; |
72 | this.intentSynchronizer = intentSynchronizer; | 69 | this.intentSynchronizer = intentSynchronizer; |
73 | this.configService = configService; | 70 | this.configService = configService; |
74 | - this.interfaceService = interfaceService; | ||
75 | } | 71 | } |
76 | 72 | ||
77 | /** | 73 | /** |
78 | * Starts the peer connectivity manager. | 74 | * Starts the peer connectivity manager. |
79 | */ | 75 | */ |
80 | public void start() { | 76 | public void start() { |
81 | - if (interfaceService.getInterfaces().isEmpty()) { | 77 | + if (configService.getInterfaces().isEmpty()) { |
82 | log.warn("No interfaces found in configuration file"); | 78 | log.warn("No interfaces found in configuration file"); |
83 | } | 79 | } |
84 | 80 | ||
... | @@ -142,7 +138,7 @@ public class PeerConnectivityManager { | ... | @@ -142,7 +138,7 @@ public class PeerConnectivityManager { |
142 | List<InterfaceAddress> interfaceAddresses = | 138 | List<InterfaceAddress> interfaceAddresses = |
143 | bgpSpeaker.interfaceAddresses(); | 139 | bgpSpeaker.interfaceAddresses(); |
144 | 140 | ||
145 | - Interface peerInterface = interfaceService.getInterface( | 141 | + Interface peerInterface = configService.getInterface( |
146 | bgpPeer.connectPoint()); | 142 | bgpPeer.connectPoint()); |
147 | 143 | ||
148 | if (peerInterface == null) { | 144 | if (peerInterface == null) { | ... | ... |
... | @@ -29,10 +29,9 @@ import org.onosproject.cluster.LeadershipService; | ... | @@ -29,10 +29,9 @@ import org.onosproject.cluster.LeadershipService; |
29 | import org.onosproject.config.NetworkConfigService; | 29 | import org.onosproject.config.NetworkConfigService; |
30 | import org.onosproject.core.ApplicationId; | 30 | import org.onosproject.core.ApplicationId; |
31 | import org.onosproject.core.CoreService; | 31 | import org.onosproject.core.CoreService; |
32 | -import org.onosproject.net.host.HostService; | ||
33 | import org.onosproject.net.intent.IntentService; | 32 | import org.onosproject.net.intent.IntentService; |
34 | import org.onosproject.routingapi.RoutingService; | 33 | import org.onosproject.routingapi.RoutingService; |
35 | -import org.onosproject.sdnip.config.SdnIpConfigurationReader; | 34 | +import org.onosproject.routingapi.config.RoutingConfigurationService; |
36 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
37 | 36 | ||
38 | import static org.slf4j.LoggerFactory.getLogger; | 37 | import static org.slf4j.LoggerFactory.getLogger; |
... | @@ -54,9 +53,6 @@ public class SdnIp implements SdnIpService { | ... | @@ -54,9 +53,6 @@ public class SdnIp implements SdnIpService { |
54 | protected IntentService intentService; | 53 | protected IntentService intentService; |
55 | 54 | ||
56 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 55 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
57 | - protected HostService hostService; | ||
58 | - | ||
59 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
60 | protected ClusterService clusterService; | 56 | protected ClusterService clusterService; |
61 | 57 | ||
62 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
... | @@ -65,6 +61,9 @@ public class SdnIp implements SdnIpService { | ... | @@ -65,6 +61,9 @@ public class SdnIp implements SdnIpService { |
65 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 61 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
66 | protected RoutingService routingService; | 62 | protected RoutingService routingService; |
67 | 63 | ||
64 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
65 | + protected RoutingConfigurationService config; | ||
66 | + | ||
68 | // | 67 | // |
69 | // NOTE: Unused reference - needed to guarantee that the | 68 | // NOTE: Unused reference - needed to guarantee that the |
70 | // NetworkConfigReader component is activated and the network configuration | 69 | // NetworkConfigReader component is activated and the network configuration |
... | @@ -74,7 +73,6 @@ public class SdnIp implements SdnIpService { | ... | @@ -74,7 +73,6 @@ public class SdnIp implements SdnIpService { |
74 | protected NetworkConfigService networkConfigService; | 73 | protected NetworkConfigService networkConfigService; |
75 | 74 | ||
76 | private IntentSynchronizer intentSynchronizer; | 75 | private IntentSynchronizer intentSynchronizer; |
77 | - private SdnIpConfigurationReader config; | ||
78 | private PeerConnectivityManager peerConnectivity; | 76 | private PeerConnectivityManager peerConnectivity; |
79 | 77 | ||
80 | private LeadershipEventListener leadershipEventListener = | 78 | private LeadershipEventListener leadershipEventListener = |
... | @@ -87,22 +85,16 @@ public class SdnIp implements SdnIpService { | ... | @@ -87,22 +85,16 @@ public class SdnIp implements SdnIpService { |
87 | log.info("SDN-IP started"); | 85 | log.info("SDN-IP started"); |
88 | 86 | ||
89 | appId = coreService.registerApplication(SDN_IP_APP); | 87 | appId = coreService.registerApplication(SDN_IP_APP); |
90 | - config = new SdnIpConfigurationReader(); | ||
91 | - config.readConfiguration(); | ||
92 | 88 | ||
93 | localControllerNode = clusterService.getLocalNode(); | 89 | localControllerNode = clusterService.getLocalNode(); |
94 | 90 | ||
95 | - InterfaceService interfaceService = | ||
96 | - new HostToInterfaceAdaptor(hostService); | ||
97 | - | ||
98 | intentSynchronizer = new IntentSynchronizer(appId, intentService, | 91 | intentSynchronizer = new IntentSynchronizer(appId, intentService, |
99 | - config, interfaceService); | 92 | + config); |
100 | intentSynchronizer.start(); | 93 | intentSynchronizer.start(); |
101 | 94 | ||
102 | peerConnectivity = new PeerConnectivityManager(appId, | 95 | peerConnectivity = new PeerConnectivityManager(appId, |
103 | intentSynchronizer, | 96 | intentSynchronizer, |
104 | - config, | 97 | + config); |
105 | - interfaceService); | ||
106 | peerConnectivity.start(); | 98 | peerConnectivity.start(); |
107 | 99 | ||
108 | routingService.start(intentSynchronizer); | 100 | routingService.start(intentSynchronizer); | ... | ... |
... | @@ -44,10 +44,10 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; | ... | @@ -44,10 +44,10 @@ import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
44 | import org.onosproject.routingapi.FibEntry; | 44 | import org.onosproject.routingapi.FibEntry; |
45 | import org.onosproject.routingapi.FibUpdate; | 45 | import org.onosproject.routingapi.FibUpdate; |
46 | import org.onosproject.routingapi.RouteEntry; | 46 | import org.onosproject.routingapi.RouteEntry; |
47 | +import org.onosproject.routingapi.config.BgpPeer; | ||
48 | +import org.onosproject.routingapi.config.Interface; | ||
49 | +import org.onosproject.routingapi.config.RoutingConfigurationService; | ||
47 | import org.onosproject.sdnip.IntentSynchronizer.IntentKey; | 50 | import org.onosproject.sdnip.IntentSynchronizer.IntentKey; |
48 | -import org.onosproject.sdnip.config.BgpPeer; | ||
49 | -import org.onosproject.sdnip.config.Interface; | ||
50 | -import org.onosproject.sdnip.config.SdnIpConfigurationService; | ||
51 | 51 | ||
52 | import java.util.Collections; | 52 | import java.util.Collections; |
53 | import java.util.HashMap; | 53 | import java.util.HashMap; |
... | @@ -70,8 +70,7 @@ import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId; | ... | @@ -70,8 +70,7 @@ import static org.onosproject.sdnip.TestIntentServiceHelper.eqExceptId; |
70 | */ | 70 | */ |
71 | public class IntentSyncTest extends AbstractIntentTest { | 71 | public class IntentSyncTest extends AbstractIntentTest { |
72 | 72 | ||
73 | - private SdnIpConfigurationService sdnIpConfigService; | 73 | + private RoutingConfigurationService routingConfig; |
74 | - private InterfaceService interfaceService; | ||
75 | private IntentService intentService; | 74 | private IntentService intentService; |
76 | 75 | ||
77 | private static final ConnectPoint SW1_ETH1 = new ConnectPoint( | 76 | private static final ConnectPoint SW1_ETH1 = new ConnectPoint( |
... | @@ -107,13 +106,19 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -107,13 +106,19 @@ public class IntentSyncTest extends AbstractIntentTest { |
107 | @Before | 106 | @Before |
108 | public void setUp() throws Exception { | 107 | public void setUp() throws Exception { |
109 | super.setUp(); | 108 | super.setUp(); |
110 | - setUpInterfaceService(); | ||
111 | 109 | ||
110 | + routingConfig = createMock(RoutingConfigurationService.class); | ||
111 | + | ||
112 | + // These will set expectations on routingConfig | ||
113 | + setUpInterfaceService(); | ||
112 | setUpBgpPeers(); | 114 | setUpBgpPeers(); |
115 | + | ||
116 | + replay(routingConfig); | ||
117 | + | ||
113 | intentService = createMock(IntentService.class); | 118 | intentService = createMock(IntentService.class); |
114 | 119 | ||
115 | intentSynchronizer = new IntentSynchronizer(APPID, intentService, | 120 | intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
116 | - sdnIpConfigService, interfaceService); | 121 | + routingConfig); |
117 | } | 122 | } |
118 | 123 | ||
119 | /** | 124 | /** |
... | @@ -140,10 +145,7 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -140,10 +145,7 @@ public class IntentSyncTest extends AbstractIntentTest { |
140 | peers.put(IpAddress.valueOf(peer1Sw4Eth1), | 145 | peers.put(IpAddress.valueOf(peer1Sw4Eth1), |
141 | new BgpPeer("00:00:00:00:00:00:00:04", 1, peer1Sw4Eth1)); | 146 | new BgpPeer("00:00:00:00:00:00:00:04", 1, peer1Sw4Eth1)); |
142 | 147 | ||
143 | - sdnIpConfigService = createMock(SdnIpConfigurationService.class); | 148 | + expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
144 | - expect(sdnIpConfigService.getBgpPeers()).andReturn(peers).anyTimes(); | ||
145 | - replay(sdnIpConfigService); | ||
146 | - | ||
147 | } | 149 | } |
148 | 150 | ||
149 | /** | 151 | /** |
... | @@ -151,8 +153,6 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -151,8 +153,6 @@ public class IntentSyncTest extends AbstractIntentTest { |
151 | */ | 153 | */ |
152 | private void setUpInterfaceService() { | 154 | private void setUpInterfaceService() { |
153 | 155 | ||
154 | - interfaceService = createMock(InterfaceService.class); | ||
155 | - | ||
156 | Set<Interface> interfaces = Sets.newHashSet(); | 156 | Set<Interface> interfaces = Sets.newHashSet(); |
157 | 157 | ||
158 | Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet(); | 158 | Set<InterfaceIpAddress> interfaceIpAddresses1 = Sets.newHashSet(); |
... | @@ -190,17 +190,16 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -190,17 +190,16 @@ public class IntentSyncTest extends AbstractIntentTest { |
190 | MacAddress.valueOf("00:00:00:00:00:04"), | 190 | MacAddress.valueOf("00:00:00:00:00:04"), |
191 | VlanId.vlanId((short) 1)); | 191 | VlanId.vlanId((short) 1)); |
192 | 192 | ||
193 | - expect(interfaceService.getInterface(SW4_ETH1)).andReturn(sw4Eth1).anyTimes(); | 193 | + expect(routingConfig.getInterface(SW4_ETH1)).andReturn( |
194 | + sw4Eth1).anyTimes(); | ||
194 | interfaces.add(sw4Eth1); | 195 | interfaces.add(sw4Eth1); |
195 | 196 | ||
196 | - expect(interfaceService.getInterface(SW1_ETH1)).andReturn( | 197 | + expect(routingConfig.getInterface(SW1_ETH1)).andReturn( |
197 | sw1Eth1).anyTimes(); | 198 | sw1Eth1).anyTimes(); |
198 | - expect(interfaceService.getInterface(SW2_ETH1)).andReturn( | 199 | + expect(routingConfig.getInterface(SW2_ETH1)).andReturn( |
199 | sw2Eth1).anyTimes(); | 200 | sw2Eth1).anyTimes(); |
200 | - expect(interfaceService.getInterface(SW3_ETH1)).andReturn( | 201 | + expect(routingConfig.getInterface(SW3_ETH1)).andReturn(sw3Eth1).anyTimes(); |
201 | - sw3Eth1).anyTimes(); | 202 | + expect(routingConfig.getInterfaces()).andReturn(interfaces).anyTimes(); |
202 | - expect(interfaceService.getInterfaces()).andReturn(interfaces).anyTimes(); | ||
203 | - replay(interfaceService); | ||
204 | } | 203 | } |
205 | 204 | ||
206 | /** | 205 | /** |
... | @@ -517,7 +516,7 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -517,7 +516,7 @@ public class IntentSyncTest extends AbstractIntentTest { |
517 | 516 | ||
518 | // Set up expectation | 517 | // Set up expectation |
519 | reset(intentService); | 518 | reset(intentService); |
520 | - Set<Intent> intents = new HashSet<Intent>(); | 519 | + Set<Intent> intents = new HashSet<>(); |
521 | intents.add(intent1); | 520 | intents.add(intent1); |
522 | expect(intentService.getIntentState(intent1.key())) | 521 | expect(intentService.getIntentState(intent1.key())) |
523 | .andReturn(IntentState.INSTALLED).anyTimes(); | 522 | .andReturn(IntentState.INSTALLED).anyTimes(); |
... | @@ -584,9 +583,9 @@ public class IntentSyncTest extends AbstractIntentTest { | ... | @@ -584,9 +583,9 @@ public class IntentSyncTest extends AbstractIntentTest { |
584 | DefaultTrafficTreatment.builder(); | 583 | DefaultTrafficTreatment.builder(); |
585 | treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress)); | 584 | treatmentBuilder.setEthDst(MacAddress.valueOf(nextHopMacAddress)); |
586 | 585 | ||
587 | - Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>(); | 586 | + Set<ConnectPoint> ingressPoints = new HashSet<>(); |
588 | - for (Interface intf : interfaceService.getInterfaces()) { | 587 | + for (Interface intf : routingConfig.getInterfaces()) { |
589 | - if (!intf.equals(interfaceService.getInterface(egressPoint))) { | 588 | + if (!intf.equals(routingConfig.getInterface(egressPoint))) { |
590 | ConnectPoint srcPort = intf.connectPoint(); | 589 | ConnectPoint srcPort = intf.connectPoint(); |
591 | ingressPoints.add(srcPort); | 590 | ingressPoints.add(srcPort); |
592 | } | 591 | } | ... | ... |
... | @@ -40,11 +40,11 @@ import org.onosproject.net.intent.AbstractIntentTest; | ... | @@ -40,11 +40,11 @@ import org.onosproject.net.intent.AbstractIntentTest; |
40 | import org.onosproject.net.intent.Intent; | 40 | import org.onosproject.net.intent.Intent; |
41 | import org.onosproject.net.intent.IntentService; | 41 | import org.onosproject.net.intent.IntentService; |
42 | import org.onosproject.net.intent.PointToPointIntent; | 42 | import org.onosproject.net.intent.PointToPointIntent; |
43 | -import org.onosproject.sdnip.config.BgpPeer; | 43 | +import org.onosproject.routingapi.config.BgpPeer; |
44 | -import org.onosproject.sdnip.config.BgpSpeaker; | 44 | +import org.onosproject.routingapi.config.BgpSpeaker; |
45 | -import org.onosproject.sdnip.config.Interface; | 45 | +import org.onosproject.routingapi.config.Interface; |
46 | -import org.onosproject.sdnip.config.InterfaceAddress; | 46 | +import org.onosproject.routingapi.config.InterfaceAddress; |
47 | -import org.onosproject.sdnip.config.SdnIpConfigurationService; | 47 | +import org.onosproject.routingapi.config.RoutingConfigurationService; |
48 | 48 | ||
49 | import java.util.ArrayList; | 49 | import java.util.ArrayList; |
50 | import java.util.Collections; | 50 | import java.util.Collections; |
... | @@ -75,8 +75,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -75,8 +75,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
75 | 75 | ||
76 | private PeerConnectivityManager peerConnectivityManager; | 76 | private PeerConnectivityManager peerConnectivityManager; |
77 | private IntentSynchronizer intentSynchronizer; | 77 | private IntentSynchronizer intentSynchronizer; |
78 | - private SdnIpConfigurationService configInfoService; | 78 | + private RoutingConfigurationService routingConfig; |
79 | - private InterfaceService interfaceService; | ||
80 | private IntentService intentService; | 79 | private IntentService intentService; |
81 | 80 | ||
82 | private Map<String, BgpSpeaker> bgpSpeakers; | 81 | private Map<String, BgpSpeaker> bgpSpeakers; |
... | @@ -114,6 +113,9 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -114,6 +113,9 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
114 | @Before | 113 | @Before |
115 | public void setUp() throws Exception { | 114 | public void setUp() throws Exception { |
116 | super.setUp(); | 115 | super.setUp(); |
116 | + routingConfig = createMock(RoutingConfigurationService.class); | ||
117 | + | ||
118 | + // These will set expectations on routingConfig | ||
117 | bgpSpeakers = Collections.unmodifiableMap(setUpBgpSpeakers()); | 119 | bgpSpeakers = Collections.unmodifiableMap(setUpBgpSpeakers()); |
118 | interfaces = Collections.unmodifiableMap(setUpInterfaces()); | 120 | interfaces = Collections.unmodifiableMap(setUpInterfaces()); |
119 | peers = Collections.unmodifiableMap(setUpPeers()); | 121 | peers = Collections.unmodifiableMap(setUpPeers()); |
... | @@ -135,8 +137,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -135,8 +137,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
135 | "bgpSpeaker1", | 137 | "bgpSpeaker1", |
136 | "00:00:00:00:00:00:00:01", 100, | 138 | "00:00:00:00:00:00:00:01", 100, |
137 | "00:00:00:00:00:01"); | 139 | "00:00:00:00:00:01"); |
138 | - List<InterfaceAddress> interfaceAddresses1 = | 140 | + List<InterfaceAddress> interfaceAddresses1 = new LinkedList<>(); |
139 | - new LinkedList<InterfaceAddress>(); | ||
140 | interfaceAddresses1.add(new InterfaceAddress(dpid1, 1, "192.168.10.101")); | 141 | interfaceAddresses1.add(new InterfaceAddress(dpid1, 1, "192.168.10.101")); |
141 | interfaceAddresses1.add(new InterfaceAddress(dpid2, 1, "192.168.20.101")); | 142 | interfaceAddresses1.add(new InterfaceAddress(dpid2, 1, "192.168.20.101")); |
142 | bgpSpeaker1.setInterfaceAddresses(interfaceAddresses1); | 143 | bgpSpeaker1.setInterfaceAddresses(interfaceAddresses1); |
... | @@ -147,8 +148,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -147,8 +148,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
147 | "bgpSpeaker2", | 148 | "bgpSpeaker2", |
148 | "00:00:00:00:00:00:00:01", 100, | 149 | "00:00:00:00:00:00:00:01", 100, |
149 | "00:00:00:00:00:02"); | 150 | "00:00:00:00:00:02"); |
150 | - List<InterfaceAddress> interfaceAddresses2 = | 151 | + List<InterfaceAddress> interfaceAddresses2 = new LinkedList<>(); |
151 | - new LinkedList<InterfaceAddress>(); | ||
152 | interfaceAddresses2.add(new InterfaceAddress(dpid1, 1, "192.168.10.102")); | 152 | interfaceAddresses2.add(new InterfaceAddress(dpid1, 1, "192.168.10.102")); |
153 | interfaceAddresses2.add(new InterfaceAddress(dpid2, 1, "192.168.20.102")); | 153 | interfaceAddresses2.add(new InterfaceAddress(dpid2, 1, "192.168.20.102")); |
154 | bgpSpeaker2.setInterfaceAddresses(interfaceAddresses2); | 154 | bgpSpeaker2.setInterfaceAddresses(interfaceAddresses2); |
... | @@ -158,8 +158,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -158,8 +158,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
158 | "bgpSpeaker3", | 158 | "bgpSpeaker3", |
159 | "00:00:00:00:00:00:00:02", 100, | 159 | "00:00:00:00:00:00:00:02", 100, |
160 | "00:00:00:00:00:03"); | 160 | "00:00:00:00:00:03"); |
161 | - List<InterfaceAddress> interfaceAddresses3 = | 161 | + List<InterfaceAddress> interfaceAddresses3 = new LinkedList<>(); |
162 | - new LinkedList<InterfaceAddress>(); | ||
163 | interfaceAddresses3.add(new InterfaceAddress(dpid1, 1, "192.168.10.103")); | 162 | interfaceAddresses3.add(new InterfaceAddress(dpid1, 1, "192.168.10.103")); |
164 | interfaceAddresses3.add(new InterfaceAddress(dpid2, 1, "192.168.20.103")); | 163 | interfaceAddresses3.add(new InterfaceAddress(dpid2, 1, "192.168.20.103")); |
165 | bgpSpeaker3.setInterfaceAddresses(interfaceAddresses3); | 164 | bgpSpeaker3.setInterfaceAddresses(interfaceAddresses3); |
... | @@ -198,22 +197,19 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -198,22 +197,19 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
198 | VlanId.NONE); | 197 | VlanId.NONE); |
199 | configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1); | 198 | configuredInterfaces.put(interfaceSw2Eth1, intfsw2eth1); |
200 | 199 | ||
201 | - interfaceService = createMock(InterfaceService.class); | 200 | + expect(routingConfig.getInterface(s1Eth1)) |
202 | - | ||
203 | - expect(interfaceService.getInterface(s1Eth1)) | ||
204 | .andReturn(intfsw1eth1).anyTimes(); | 201 | .andReturn(intfsw1eth1).anyTimes(); |
205 | - expect(interfaceService.getInterface(s2Eth1)) | 202 | + expect(routingConfig.getInterface(s2Eth1)) |
206 | .andReturn(intfsw2eth1).anyTimes(); | 203 | .andReturn(intfsw2eth1).anyTimes(); |
207 | 204 | ||
208 | // Non-existent interface used during one of the tests | 205 | // Non-existent interface used during one of the tests |
209 | - expect(interfaceService.getInterface(new ConnectPoint( | 206 | + expect(routingConfig.getInterface(new ConnectPoint( |
210 | DeviceId.deviceId(SdnIp.dpidToUri("00:00:00:00:00:00:01:00")), | 207 | DeviceId.deviceId(SdnIp.dpidToUri("00:00:00:00:00:00:01:00")), |
211 | PortNumber.portNumber(1)))) | 208 | PortNumber.portNumber(1)))) |
212 | .andReturn(null).anyTimes(); | 209 | .andReturn(null).anyTimes(); |
213 | 210 | ||
214 | - expect(interfaceService.getInterfaces()).andReturn( | 211 | + expect(routingConfig.getInterfaces()).andReturn( |
215 | Sets.newHashSet(configuredInterfaces.values())).anyTimes(); | 212 | Sets.newHashSet(configuredInterfaces.values())).anyTimes(); |
216 | - replay(interfaceService); | ||
217 | 213 | ||
218 | return configuredInterfaces; | 214 | return configuredInterfaces; |
219 | } | 215 | } |
... | @@ -250,7 +246,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -250,7 +246,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
250 | */ | 246 | */ |
251 | private List<PointToPointIntent> setUpIntentList() { | 247 | private List<PointToPointIntent> setUpIntentList() { |
252 | 248 | ||
253 | - intentList = new ArrayList<PointToPointIntent>(); | 249 | + intentList = new ArrayList<>(); |
254 | 250 | ||
255 | setUpBgpIntents(); | 251 | setUpBgpIntents(); |
256 | setUpIcmpIntents(); | 252 | setUpIcmpIntents(); |
... | @@ -538,23 +534,21 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -538,23 +534,21 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
538 | */ | 534 | */ |
539 | private void initPeerConnectivity() throws TestUtilsException { | 535 | private void initPeerConnectivity() throws TestUtilsException { |
540 | 536 | ||
541 | - configInfoService = createMock(SdnIpConfigurationService.class); | 537 | + expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
542 | - expect(configInfoService.getBgpPeers()).andReturn(peers).anyTimes(); | 538 | + expect(routingConfig.getBgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); |
543 | - expect(configInfoService.getBgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); | 539 | + replay(routingConfig); |
544 | - replay(configInfoService); | ||
545 | 540 | ||
546 | intentService = createMock(IntentService.class); | 541 | intentService = createMock(IntentService.class); |
547 | replay(intentService); | 542 | replay(intentService); |
548 | 543 | ||
549 | intentSynchronizer = new IntentSynchronizer(APPID, intentService, | 544 | intentSynchronizer = new IntentSynchronizer(APPID, intentService, |
550 | - configInfoService, | 545 | + routingConfig); |
551 | - interfaceService); | ||
552 | intentSynchronizer.leaderChanged(true); | 546 | intentSynchronizer.leaderChanged(true); |
553 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); | 547 | TestUtils.setField(intentSynchronizer, "isActivatedLeader", true); |
554 | 548 | ||
555 | peerConnectivityManager = | 549 | peerConnectivityManager = |
556 | new PeerConnectivityManager(APPID, intentSynchronizer, | 550 | new PeerConnectivityManager(APPID, intentSynchronizer, |
557 | - configInfoService, interfaceService); | 551 | + routingConfig); |
558 | } | 552 | } |
559 | 553 | ||
560 | /** | 554 | /** |
... | @@ -587,19 +581,17 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -587,19 +581,17 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
587 | */ | 581 | */ |
588 | @Test | 582 | @Test |
589 | public void testNullInterfaces() { | 583 | public void testNullInterfaces() { |
590 | - reset(interfaceService); | 584 | + reset(routingConfig); |
591 | - expect(interfaceService.getInterfaces()).andReturn( | 585 | + expect(routingConfig.getInterfaces()).andReturn( |
592 | Sets.<Interface>newHashSet()).anyTimes(); | 586 | Sets.<Interface>newHashSet()).anyTimes(); |
593 | - expect(interfaceService.getInterface(s2Eth1)) | 587 | + expect(routingConfig.getInterface(s2Eth1)) |
594 | .andReturn(null).anyTimes(); | 588 | .andReturn(null).anyTimes(); |
595 | - expect(interfaceService.getInterface(s1Eth1)) | 589 | + expect(routingConfig.getInterface(s1Eth1)) |
596 | .andReturn(null).anyTimes(); | 590 | .andReturn(null).anyTimes(); |
597 | - replay(interfaceService); | ||
598 | 591 | ||
599 | - reset(configInfoService); | 592 | + expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
600 | - expect(configInfoService.getBgpPeers()).andReturn(peers).anyTimes(); | 593 | + expect(routingConfig.getBgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); |
601 | - expect(configInfoService.getBgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); | 594 | + replay(routingConfig); |
602 | - replay(configInfoService); | ||
603 | 595 | ||
604 | reset(intentService); | 596 | reset(intentService); |
605 | replay(intentService); | 597 | replay(intentService); |
... | @@ -612,17 +604,13 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -612,17 +604,13 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
612 | */ | 604 | */ |
613 | @Test | 605 | @Test |
614 | public void testNullBgpPeers() { | 606 | public void testNullBgpPeers() { |
615 | - reset(interfaceService); | 607 | + reset(routingConfig); |
616 | - expect(interfaceService.getInterfaces()).andReturn( | 608 | + expect(routingConfig.getInterfaces()).andReturn( |
617 | Sets.newHashSet(interfaces.values())).anyTimes(); | 609 | Sets.newHashSet(interfaces.values())).anyTimes(); |
618 | - replay(interfaceService); | ||
619 | 610 | ||
620 | - reset(configInfoService); | 611 | + expect(routingConfig.getBgpPeers()).andReturn(new HashMap<>()).anyTimes(); |
621 | - expect(configInfoService.getBgpPeers()).andReturn( | 612 | + expect(routingConfig.getBgpSpeakers()).andReturn(bgpSpeakers).anyTimes(); |
622 | - new HashMap<IpAddress, BgpPeer>()).anyTimes(); | 613 | + replay(routingConfig); |
623 | - expect(configInfoService.getBgpSpeakers()).andReturn( | ||
624 | - bgpSpeakers).anyTimes(); | ||
625 | - replay(configInfoService); | ||
626 | 614 | ||
627 | reset(intentService); | 615 | reset(intentService); |
628 | replay(intentService); | 616 | replay(intentService); |
... | @@ -635,17 +623,14 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -635,17 +623,14 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
635 | */ | 623 | */ |
636 | @Test | 624 | @Test |
637 | public void testNullBgpSpeakers() { | 625 | public void testNullBgpSpeakers() { |
638 | - reset(interfaceService); | 626 | + reset(routingConfig); |
639 | - expect(interfaceService.getInterfaces()).andReturn( | 627 | + expect(routingConfig.getInterfaces()).andReturn( |
640 | Sets.newHashSet(interfaces.values())).anyTimes(); | 628 | Sets.newHashSet(interfaces.values())).anyTimes(); |
641 | - replay(interfaceService); | ||
642 | 629 | ||
643 | - reset(configInfoService); | 630 | + expect(routingConfig.getBgpPeers()).andReturn(peers).anyTimes(); |
644 | - expect(configInfoService.getBgpPeers()).andReturn( | 631 | + expect(routingConfig.getBgpSpeakers()).andReturn( |
645 | - peers).anyTimes(); | ||
646 | - expect(configInfoService.getBgpSpeakers()).andReturn( | ||
647 | Collections.emptyMap()).anyTimes(); | 632 | Collections.emptyMap()).anyTimes(); |
648 | - replay(configInfoService); | 633 | + replay(routingConfig); |
649 | 634 | ||
650 | reset(intentService); | 635 | reset(intentService); |
651 | replay(intentService); | 636 | replay(intentService); |
... | @@ -676,8 +661,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { | ... | @@ -676,8 +661,7 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { |
676 | "bgpSpeaker100", | 661 | "bgpSpeaker100", |
677 | "00:00:00:00:00:00:01:00", 100, | 662 | "00:00:00:00:00:00:01:00", 100, |
678 | "00:00:00:00:01:00"); | 663 | "00:00:00:00:01:00"); |
679 | - List<InterfaceAddress> interfaceAddresses100 = | 664 | + List<InterfaceAddress> interfaceAddresses100 = new LinkedList<>(); |
680 | - new LinkedList<InterfaceAddress>(); | ||
681 | interfaceAddresses100.add(new InterfaceAddress(dpid1, 1, "192.168.10.201")); | 665 | interfaceAddresses100.add(new InterfaceAddress(dpid1, 1, "192.168.10.201")); |
682 | interfaceAddresses100.add(new InterfaceAddress(dpid2, 1, "192.168.20.201")); | 666 | interfaceAddresses100.add(new InterfaceAddress(dpid2, 1, "192.168.20.201")); |
683 | bgpSpeaker100.setInterfaceAddresses(interfaceAddresses100); | 667 | bgpSpeaker100.setInterfaceAddresses(interfaceAddresses100); | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2014 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -13,29 +13,25 @@ | ... | @@ -13,29 +13,25 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.sdnip.config; | 16 | +package org.onosproject.net; |
17 | - | ||
18 | -import java.util.Map; | ||
19 | - | ||
20 | -import org.onlab.packet.IpAddress; | ||
21 | 17 | ||
22 | /** | 18 | /** |
23 | - * Provides information about the BGP elements configured in the network. | 19 | + * Networking domain tools. |
24 | */ | 20 | */ |
25 | -public interface SdnIpConfigurationService { | 21 | +public final class NetTools { |
26 | 22 | ||
27 | - /** | 23 | + private NetTools() { |
28 | - * Gets the list of BGP speakers inside the SDN network. | 24 | + } |
29 | - * | ||
30 | - * @return the map of BGP speaker names to BGP speaker objects | ||
31 | - */ | ||
32 | - public Map<String, BgpSpeaker> getBgpSpeakers(); | ||
33 | 25 | ||
34 | /** | 26 | /** |
35 | - * Gets the list of configured BGP peers. | 27 | + * Converts DPIDs of the form xx:xx:xx:xx:xx:xx:xx to OpenFlow provider |
28 | + * device URIs. The is helpful for converting DPIDs coming from configuration | ||
29 | + * or REST to URIs that the core understands. | ||
36 | * | 30 | * |
37 | - * @return the map from peer IP address to BgpPeer object | 31 | + * @param dpid the DPID string to convert |
32 | + * @return the URI string for this device | ||
38 | */ | 33 | */ |
39 | - public Map<IpAddress, BgpPeer> getBgpPeers(); | 34 | + public static String dpidToUri(String dpid) { |
40 | - | 35 | + return "of:" + dpid.replace(":", ""); |
36 | + } | ||
41 | } | 37 | } | ... | ... |
-
Please register or login to post a comment