Avantika-Huawei
Committed by Gerrit Code Review

[GoldenEye] [ONOS-4163] Add provider service API

Change-Id: I363471d3a69a1c67d57d853fb84d42551eb27b7a
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
17 package org.onosproject.incubator.net.tunnel; 17 package org.onosproject.incubator.net.tunnel;
18 18
19 import com.google.common.annotations.Beta; 19 import com.google.common.annotations.Beta;
20 +
21 +import org.onosproject.incubator.net.tunnel.Tunnel.State;
20 import org.onosproject.net.provider.ProviderService; 22 import org.onosproject.net.provider.ProviderService;
21 23
22 /** 24 /**
...@@ -34,6 +36,16 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> { ...@@ -34,6 +36,16 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> {
34 TunnelId tunnelAdded(TunnelDescription tunnel); 36 TunnelId tunnelAdded(TunnelDescription tunnel);
35 37
36 /** 38 /**
39 + * Signals that the provider has added a tunnel with a status which may not
40 + * be default, hence is provided as an input.
41 + *
42 + * @param tunnel tunnel information
43 + * @param state tunnel working status
44 + * @return tunnel identity
45 + */
46 + TunnelId tunnelAdded(TunnelDescription tunnel, State state);
47 +
48 + /**
37 * Signals that the provider has removed a tunnel. 49 * Signals that the provider has removed a tunnel.
38 * 50 *
39 * @param tunnel tunnel information 51 * @param tunnel tunnel information
......
...@@ -25,6 +25,7 @@ import org.onosproject.net.provider.AbstractListenerProviderRegistry; ...@@ -25,6 +25,7 @@ import org.onosproject.net.provider.AbstractListenerProviderRegistry;
25 import org.onosproject.core.ApplicationId; 25 import org.onosproject.core.ApplicationId;
26 import org.onosproject.incubator.net.tunnel.DefaultTunnel; 26 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
27 import org.onosproject.incubator.net.tunnel.Tunnel; 27 import org.onosproject.incubator.net.tunnel.Tunnel;
28 +import org.onosproject.incubator.net.tunnel.Tunnel.State;
28 import org.onosproject.incubator.net.tunnel.Tunnel.Type; 29 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
29 import org.onosproject.incubator.net.tunnel.TunnelAdminService; 30 import org.onosproject.incubator.net.tunnel.TunnelAdminService;
30 import org.onosproject.incubator.net.tunnel.TunnelDescription; 31 import org.onosproject.incubator.net.tunnel.TunnelDescription;
...@@ -309,6 +310,20 @@ public class TunnelManager ...@@ -309,6 +310,20 @@ public class TunnelManager
309 } 310 }
310 311
311 @Override 312 @Override
313 + public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
314 + Tunnel storedTunnel = new DefaultTunnel(provider().id(),
315 + tunnel.src(), tunnel.dst(),
316 + tunnel.type(),
317 + state,
318 + tunnel.groupId(),
319 + tunnel.id(),
320 + tunnel.tunnelName(),
321 + tunnel.path(),
322 + tunnel.annotations());
323 + return store.createOrUpdateTunnel(storedTunnel);
324 + }
325 +
326 + @Override
312 public void tunnelUpdated(TunnelDescription tunnel) { 327 public void tunnelUpdated(TunnelDescription tunnel) {
313 Tunnel storedTunnel = new DefaultTunnel(provider().id(), 328 Tunnel storedTunnel = new DefaultTunnel(provider().id(),
314 tunnel.src(), tunnel.dst(), 329 tunnel.src(), tunnel.dst(),
......
...@@ -38,6 +38,7 @@ import org.onosproject.incubator.net.tunnel.TunnelName; ...@@ -38,6 +38,7 @@ import org.onosproject.incubator.net.tunnel.TunnelName;
38 import org.onosproject.incubator.net.tunnel.TunnelProvider; 38 import org.onosproject.incubator.net.tunnel.TunnelProvider;
39 import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry; 39 import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
40 import org.onosproject.incubator.net.tunnel.TunnelProviderService; 40 import org.onosproject.incubator.net.tunnel.TunnelProviderService;
41 +import org.onosproject.incubator.net.tunnel.Tunnel.State;
41 import org.onosproject.net.ConnectPoint; 42 import org.onosproject.net.ConnectPoint;
42 import org.onosproject.net.DefaultAnnotations; 43 import org.onosproject.net.DefaultAnnotations;
43 import org.onosproject.net.DefaultLink; 44 import org.onosproject.net.DefaultLink;
...@@ -166,6 +167,11 @@ public class OvsdbTunnelProviderTest { ...@@ -166,6 +167,11 @@ public class OvsdbTunnelProviderTest {
166 } 167 }
167 168
168 @Override 169 @Override
170 + public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
171 + return null;
172 + }
173 +
174 + @Override
169 public void tunnelRemoved(TunnelDescription tunnel) { 175 public void tunnelRemoved(TunnelDescription tunnel) {
170 tunnelSet.remove(tunnel); 176 tunnelSet.remove(tunnel);
171 } 177 }
......
...@@ -23,6 +23,7 @@ import org.onosproject.incubator.net.tunnel.TunnelId; ...@@ -23,6 +23,7 @@ import org.onosproject.incubator.net.tunnel.TunnelId;
23 import org.onosproject.incubator.net.tunnel.TunnelProvider; 23 import org.onosproject.incubator.net.tunnel.TunnelProvider;
24 import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry; 24 import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
25 import org.onosproject.incubator.net.tunnel.TunnelProviderService; 25 import org.onosproject.incubator.net.tunnel.TunnelProviderService;
26 +import org.onosproject.incubator.net.tunnel.Tunnel.State;
26 import org.onosproject.net.provider.ProviderId; 27 import org.onosproject.net.provider.ProviderId;
27 28
28 public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry { 29 public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry {
...@@ -56,6 +57,11 @@ public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry { ...@@ -56,6 +57,11 @@ public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry {
56 } 57 }
57 58
58 @Override 59 @Override
60 + public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
61 + return null;
62 + }
63 +
64 + @Override
59 public void tunnelRemoved(TunnelDescription tunnel) { 65 public void tunnelRemoved(TunnelDescription tunnel) {
60 } 66 }
61 67
......