Avantika-Huawei
Committed by Gerrit Code Review

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

Change-Id: I363471d3a69a1c67d57d853fb84d42551eb27b7a
......@@ -17,6 +17,8 @@
package org.onosproject.incubator.net.tunnel;
import com.google.common.annotations.Beta;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
import org.onosproject.net.provider.ProviderService;
/**
......@@ -34,6 +36,16 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> {
TunnelId tunnelAdded(TunnelDescription tunnel);
/**
* Signals that the provider has added a tunnel with a status which may not
* be default, hence is provided as an input.
*
* @param tunnel tunnel information
* @param state tunnel working status
* @return tunnel identity
*/
TunnelId tunnelAdded(TunnelDescription tunnel, State state);
/**
* Signals that the provider has removed a tunnel.
*
* @param tunnel tunnel information
......
......@@ -25,6 +25,7 @@ import org.onosproject.net.provider.AbstractListenerProviderRegistry;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.incubator.net.tunnel.TunnelAdminService;
import org.onosproject.incubator.net.tunnel.TunnelDescription;
......@@ -309,6 +310,20 @@ public class TunnelManager
}
@Override
public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
Tunnel storedTunnel = new DefaultTunnel(provider().id(),
tunnel.src(), tunnel.dst(),
tunnel.type(),
state,
tunnel.groupId(),
tunnel.id(),
tunnel.tunnelName(),
tunnel.path(),
tunnel.annotations());
return store.createOrUpdateTunnel(storedTunnel);
}
@Override
public void tunnelUpdated(TunnelDescription tunnel) {
Tunnel storedTunnel = new DefaultTunnel(provider().id(),
tunnel.src(), tunnel.dst(),
......
......@@ -38,6 +38,7 @@ import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.incubator.net.tunnel.TunnelProvider;
import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
import org.onosproject.incubator.net.tunnel.TunnelProviderService;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
......@@ -166,6 +167,11 @@ public class OvsdbTunnelProviderTest {
}
@Override
public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
return null;
}
@Override
public void tunnelRemoved(TunnelDescription tunnel) {
tunnelSet.remove(tunnel);
}
......
......@@ -23,6 +23,7 @@ import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelProvider;
import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
import org.onosproject.incubator.net.tunnel.TunnelProviderService;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
import org.onosproject.net.provider.ProviderId;
public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry {
......@@ -56,6 +57,11 @@ public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry {
}
@Override
public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
return null;
}
@Override
public void tunnelRemoved(TunnelDescription tunnel) {
}
......