Committed by
Gerrit Code Review
ONOS-4401 VPLS: react to intf config changes.
Change-Id: Id34a9de669a3ab571e690b27072b44057d863768
Showing
2 changed files
with
38 additions
and
9 deletions
... | @@ -28,6 +28,8 @@ import org.onlab.packet.VlanId; | ... | @@ -28,6 +28,8 @@ import org.onlab.packet.VlanId; |
28 | import org.onosproject.app.ApplicationService; | 28 | import org.onosproject.app.ApplicationService; |
29 | import org.onosproject.core.ApplicationId; | 29 | import org.onosproject.core.ApplicationId; |
30 | import org.onosproject.core.CoreService; | 30 | import org.onosproject.core.CoreService; |
31 | +import org.onosproject.incubator.net.intf.InterfaceEvent; | ||
32 | +import org.onosproject.incubator.net.intf.InterfaceListener; | ||
31 | import org.onosproject.incubator.net.intf.InterfaceService; | 33 | import org.onosproject.incubator.net.intf.InterfaceService; |
32 | import org.onosproject.net.ConnectPoint; | 34 | import org.onosproject.net.ConnectPoint; |
33 | import org.onosproject.net.Host; | 35 | import org.onosproject.net.Host; |
... | @@ -75,6 +77,9 @@ public class Vpls { | ... | @@ -75,6 +77,9 @@ public class Vpls { |
75 | 77 | ||
76 | private final HostListener hostListener = new InternalHostListener(); | 78 | private final HostListener hostListener = new InternalHostListener(); |
77 | 79 | ||
80 | + private final InternalInterfaceListener interfaceListener | ||
81 | + = new InternalInterfaceListener(); | ||
82 | + | ||
78 | private IntentInstaller intentInstaller; | 83 | private IntentInstaller intentInstaller; |
79 | 84 | ||
80 | private ApplicationId appId; | 85 | private ApplicationId appId; |
... | @@ -91,6 +96,7 @@ public class Vpls { | ... | @@ -91,6 +96,7 @@ public class Vpls { |
91 | intentSynchronizerAdmin::removeIntents); | 96 | intentSynchronizerAdmin::removeIntents); |
92 | 97 | ||
93 | hostService.addListener(hostListener); | 98 | hostService.addListener(hostListener); |
99 | + interfaceService.addListener(interfaceListener); | ||
94 | 100 | ||
95 | setupConnectivity(); | 101 | setupConnectivity(); |
96 | 102 | ||
... | @@ -200,4 +206,23 @@ public class Vpls { | ... | @@ -200,4 +206,23 @@ public class Vpls { |
200 | } | 206 | } |
201 | } | 207 | } |
202 | } | 208 | } |
209 | + | ||
210 | + /** | ||
211 | + * Listener for interface configuration events. | ||
212 | + */ | ||
213 | + private class InternalInterfaceListener implements InterfaceListener { | ||
214 | + @Override | ||
215 | + public void event(InterfaceEvent event) { | ||
216 | + log.debug("Received InterfaceConfigEvent {}", event); | ||
217 | + switch (event.type()) { | ||
218 | + case INTERFACE_ADDED: | ||
219 | + case INTERFACE_UPDATED: | ||
220 | + case INTERFACE_REMOVED: | ||
221 | + setupConnectivity(); | ||
222 | + break; | ||
223 | + default: | ||
224 | + break; | ||
225 | + } | ||
226 | + } | ||
227 | + } | ||
203 | } | 228 | } | ... | ... |
... | @@ -28,6 +28,7 @@ import org.onosproject.core.ApplicationId; | ... | @@ -28,6 +28,7 @@ import org.onosproject.core.ApplicationId; |
28 | import org.onosproject.core.CoreService; | 28 | import org.onosproject.core.CoreService; |
29 | import org.onosproject.core.IdGenerator; | 29 | import org.onosproject.core.IdGenerator; |
30 | import org.onosproject.incubator.net.intf.Interface; | 30 | import org.onosproject.incubator.net.intf.Interface; |
31 | +import org.onosproject.incubator.net.intf.InterfaceListener; | ||
31 | import org.onosproject.incubator.net.intf.InterfaceService; | 32 | import org.onosproject.incubator.net.intf.InterfaceService; |
32 | import org.onosproject.net.ConnectPoint; | 33 | import org.onosproject.net.ConnectPoint; |
33 | import org.onosproject.net.DefaultHost; | 34 | import org.onosproject.net.DefaultHost; |
... | @@ -57,16 +58,14 @@ import org.onosproject.routing.IntentSynchronizationService; | ... | @@ -57,16 +58,14 @@ import org.onosproject.routing.IntentSynchronizationService; |
57 | 58 | ||
58 | import java.util.ArrayList; | 59 | import java.util.ArrayList; |
59 | import java.util.Collections; | 60 | import java.util.Collections; |
60 | -import java.util.HashSet; | ||
61 | import java.util.List; | 61 | import java.util.List; |
62 | import java.util.Set; | 62 | import java.util.Set; |
63 | import java.util.concurrent.atomic.AtomicLong; | 63 | import java.util.concurrent.atomic.AtomicLong; |
64 | import java.util.stream.Collectors; | 64 | import java.util.stream.Collectors; |
65 | 65 | ||
66 | import static java.lang.String.format; | 66 | import static java.lang.String.format; |
67 | -import static org.easymock.EasyMock.createMock; | 67 | +import static org.easymock.EasyMock.*; |
68 | -import static org.easymock.EasyMock.expect; | 68 | +import static org.easymock.EasyMock.expectLastCall; |
69 | -import static org.easymock.EasyMock.replay; | ||
70 | import static org.junit.Assert.assertEquals; | 69 | import static org.junit.Assert.assertEquals; |
71 | import static org.junit.Assert.assertTrue; | 70 | import static org.junit.Assert.assertTrue; |
72 | 71 | ||
... | @@ -157,6 +156,8 @@ public class VplsTest { | ... | @@ -157,6 +156,8 @@ public class VplsTest { |
157 | new TestIntentSynchronizer(intentService); | 156 | new TestIntentSynchronizer(intentService); |
158 | 157 | ||
159 | interfaceService = createMock(InterfaceService.class); | 158 | interfaceService = createMock(InterfaceService.class); |
159 | + interfaceService.addListener(anyObject(InterfaceListener.class)); | ||
160 | + expectLastCall().anyTimes(); | ||
160 | addIntfConfig(); | 161 | addIntfConfig(); |
161 | 162 | ||
162 | vpls = new Vpls(); | 163 | vpls = new Vpls(); |
... | @@ -177,21 +178,24 @@ public class VplsTest { | ... | @@ -177,21 +178,24 @@ public class VplsTest { |
177 | */ | 178 | */ |
178 | private void addIntfConfig() { | 179 | private void addIntfConfig() { |
179 | Set<Interface> interfaces = Sets.newHashSet(); | 180 | Set<Interface> interfaces = Sets.newHashSet(); |
180 | - Set<Interface> vlanOneSet = new HashSet<>(); | 181 | + Set<Interface> vlanOneSet = Sets.newHashSet(); |
181 | - Set<Interface> vlanTwoSet = new HashSet<>(); | 182 | + Set<Interface> vlanTwoSet = Sets.newHashSet(); |
182 | 183 | ||
183 | for (int i = 1; i <= NUM_DEVICES - 1; i++) { | 184 | for (int i = 1; i <= NUM_DEVICES - 1; i++) { |
184 | ConnectPoint cp = new ConnectPoint(getDeviceId(i), P1); | 185 | ConnectPoint cp = new ConnectPoint(getDeviceId(i), P1); |
185 | 186 | ||
186 | Interface intf = | 187 | Interface intf = |
187 | - new Interface(cp, Collections.emptySet(), null, VlanId.NONE); | 188 | + new Interface("intfOne", cp, Collections.emptyList(), null, |
189 | + VlanId.NONE); | ||
188 | 190 | ||
189 | if (i <= 3) { | 191 | if (i <= 3) { |
190 | - intf = new Interface(cp, Collections.emptySet(), null, VLAN1); | 192 | + intf = new Interface("intfTwo", cp, Collections.emptyList(), |
193 | + null, VLAN1); | ||
191 | interfaces.add(intf); | 194 | interfaces.add(intf); |
192 | vlanOneSet.add(intf); | 195 | vlanOneSet.add(intf); |
193 | } else if (i > 3 && i <= 6) { | 196 | } else if (i > 3 && i <= 6) { |
194 | - intf = new Interface(cp, Collections.emptySet(), null, VLAN2); | 197 | + intf = new Interface("intfThree", cp, Collections.emptyList(), |
198 | + null, VLAN2); | ||
195 | interfaces.add(intf); | 199 | interfaces.add(intf); |
196 | vlanTwoSet.add(intf); | 200 | vlanTwoSet.add(intf); |
197 | } | 201 | } | ... | ... |
-
Please register or login to post a comment