Thomas Vachuska
Committed by Gerrit Code Review

Adding vnet provider and related interfaces.

Change-Id: I72820a7dd77ad09ba7bb63f1aa8dfdf12b382030
package org.onosproject.incubator.net.virtual;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.provider.Provider;
/**
* Entity capable of providing traffic isolation constructs for use in
* implementation of virtual devices and virtual links.
*/
public interface VirtualNetworkProvider extends Provider {
/**
* Creates a network tunnel for all traffic from the specified source
* connection point to the indicated destination connection point.
*
* @param networkId virtual network identifier
* @param src source connection point
* @param dst destination connection point
*/
TunnelId createTunnel(NetworkId networkId, ConnectPoint src, ConnectPoint dst);
/**
* Destroys the specified network tunnel.
*
* @param networkId virtual network identifier
* @param tunnelId tunnel identifier
*/
void destroyTunnel(NetworkId networkId, TunnelId tunnelId);
}
/*
* 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.incubator.net.virtual;
import org.onosproject.net.provider.ProviderRegistry;
/**
* Abstraction of a virtual network provider registry.
*/
public interface VirtualNetworkProviderRegistry
extends ProviderRegistry<VirtualNetworkProvider, VirtualNetworkProviderService> {
}
package org.onosproject.incubator.net.virtual;
import org.onosproject.net.provider.ProviderService;
/**
* Service through which virtual network providers can inject information into
* the core.
*/
public interface VirtualNetworkProviderService extends ProviderService<VirtualNetworkProvider> {
// TODO: Add methods for notification of core about damaged tunnels, etc.
}
......@@ -21,7 +21,6 @@ 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.event.AbstractListenerManager;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.virtual.NetworkId;
import org.onosproject.incubator.net.virtual.TenantId;
......@@ -31,6 +30,9 @@ import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkAdminService;
import org.onosproject.incubator.net.virtual.VirtualNetworkEvent;
import org.onosproject.incubator.net.virtual.VirtualNetworkListener;
import org.onosproject.incubator.net.virtual.VirtualNetworkProvider;
import org.onosproject.incubator.net.virtual.VirtualNetworkProviderRegistry;
import org.onosproject.incubator.net.virtual.VirtualNetworkProviderService;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate;
......@@ -39,6 +41,8 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.AbstractListenerProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -52,8 +56,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Component(immediate = true)
@Service
public class VirtualNetworkManager
extends AbstractListenerManager<VirtualNetworkEvent, VirtualNetworkListener>
implements VirtualNetworkService, VirtualNetworkAdminService {
extends AbstractListenerProviderRegistry<VirtualNetworkEvent, VirtualNetworkListener,
VirtualNetworkProvider, VirtualNetworkProviderService>
implements VirtualNetworkService, VirtualNetworkAdminService, VirtualNetworkProviderRegistry {
private final Logger log = LoggerFactory.getLogger(getClass());
......@@ -67,7 +72,7 @@ public class VirtualNetworkManager
private VirtualNetworkStoreDelegate delegate = new InternalStoreDelegate();
// TODO: figure out how to coordinate "implementation" of a virtual network
// TODO: figure out how to coordinate "implementation" of a virtual network in a cluster
@Activate
protected void activate() {
......@@ -191,6 +196,21 @@ public class VirtualNetworkManager
return null;
}
@Override
protected VirtualNetworkProviderService createProviderService(VirtualNetworkProvider provider) {
return new InternalVirtualNetworkProviderService(provider);
}
// Service issued to registered virtual network providers so that they
// can interact with the core.
private class InternalVirtualNetworkProviderService
extends AbstractProviderService<VirtualNetworkProvider>
implements VirtualNetworkProviderService {
InternalVirtualNetworkProviderService(VirtualNetworkProvider provider) {
super(provider);
}
}
// Auxiliary store delegate to receive notification about changes in
// the virtual network configuration store state - by the store itself.
private class InternalStoreDelegate implements VirtualNetworkStoreDelegate {
......