Thomas Vachuska
Committed by Gerrit Code Review

Adding vnet provider and related interfaces.

Change-Id: I72820a7dd77ad09ba7bb63f1aa8dfdf12b382030
1 +package org.onosproject.incubator.net.virtual;
2 +
3 +import org.onosproject.incubator.net.tunnel.TunnelId;
4 +import org.onosproject.net.ConnectPoint;
5 +import org.onosproject.net.provider.Provider;
6 +
7 +/**
8 + * Entity capable of providing traffic isolation constructs for use in
9 + * implementation of virtual devices and virtual links.
10 + */
11 +public interface VirtualNetworkProvider extends Provider {
12 +
13 + /**
14 + * Creates a network tunnel for all traffic from the specified source
15 + * connection point to the indicated destination connection point.
16 + *
17 + * @param networkId virtual network identifier
18 + * @param src source connection point
19 + * @param dst destination connection point
20 + */
21 + TunnelId createTunnel(NetworkId networkId, ConnectPoint src, ConnectPoint dst);
22 +
23 + /**
24 + * Destroys the specified network tunnel.
25 + *
26 + * @param networkId virtual network identifier
27 + * @param tunnelId tunnel identifier
28 + */
29 + void destroyTunnel(NetworkId networkId, TunnelId tunnelId);
30 +
31 +}
1 +/*
2 + * Copyright 2014 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.incubator.net.virtual;
17 +
18 +import org.onosproject.net.provider.ProviderRegistry;
19 +
20 +/**
21 + * Abstraction of a virtual network provider registry.
22 + */
23 +public interface VirtualNetworkProviderRegistry
24 + extends ProviderRegistry<VirtualNetworkProvider, VirtualNetworkProviderService> {
25 +}
1 +package org.onosproject.incubator.net.virtual;
2 +
3 +import org.onosproject.net.provider.ProviderService;
4 +
5 +/**
6 + * Service through which virtual network providers can inject information into
7 + * the core.
8 + */
9 +public interface VirtualNetworkProviderService extends ProviderService<VirtualNetworkProvider> {
10 + // TODO: Add methods for notification of core about damaged tunnels, etc.
11 +}
...@@ -21,7 +21,6 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -21,7 +21,6 @@ import org.apache.felix.scr.annotations.Deactivate;
21 import org.apache.felix.scr.annotations.Reference; 21 import org.apache.felix.scr.annotations.Reference;
22 import org.apache.felix.scr.annotations.ReferenceCardinality; 22 import org.apache.felix.scr.annotations.ReferenceCardinality;
23 import org.apache.felix.scr.annotations.Service; 23 import org.apache.felix.scr.annotations.Service;
24 -import org.onosproject.event.AbstractListenerManager;
25 import org.onosproject.incubator.net.tunnel.TunnelId; 24 import org.onosproject.incubator.net.tunnel.TunnelId;
26 import org.onosproject.incubator.net.virtual.NetworkId; 25 import org.onosproject.incubator.net.virtual.NetworkId;
27 import org.onosproject.incubator.net.virtual.TenantId; 26 import org.onosproject.incubator.net.virtual.TenantId;
...@@ -31,6 +30,9 @@ import org.onosproject.incubator.net.virtual.VirtualNetwork; ...@@ -31,6 +30,9 @@ import org.onosproject.incubator.net.virtual.VirtualNetwork;
31 import org.onosproject.incubator.net.virtual.VirtualNetworkAdminService; 30 import org.onosproject.incubator.net.virtual.VirtualNetworkAdminService;
32 import org.onosproject.incubator.net.virtual.VirtualNetworkEvent; 31 import org.onosproject.incubator.net.virtual.VirtualNetworkEvent;
33 import org.onosproject.incubator.net.virtual.VirtualNetworkListener; 32 import org.onosproject.incubator.net.virtual.VirtualNetworkListener;
33 +import org.onosproject.incubator.net.virtual.VirtualNetworkProvider;
34 +import org.onosproject.incubator.net.virtual.VirtualNetworkProviderRegistry;
35 +import org.onosproject.incubator.net.virtual.VirtualNetworkProviderService;
34 import org.onosproject.incubator.net.virtual.VirtualNetworkService; 36 import org.onosproject.incubator.net.virtual.VirtualNetworkService;
35 import org.onosproject.incubator.net.virtual.VirtualNetworkStore; 37 import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
36 import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate; 38 import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate;
...@@ -39,6 +41,8 @@ import org.onosproject.net.ConnectPoint; ...@@ -39,6 +41,8 @@ import org.onosproject.net.ConnectPoint;
39 import org.onosproject.net.DeviceId; 41 import org.onosproject.net.DeviceId;
40 import org.onosproject.net.Port; 42 import org.onosproject.net.Port;
41 import org.onosproject.net.PortNumber; 43 import org.onosproject.net.PortNumber;
44 +import org.onosproject.net.provider.AbstractListenerProviderRegistry;
45 +import org.onosproject.net.provider.AbstractProviderService;
42 import org.slf4j.Logger; 46 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory; 47 import org.slf4j.LoggerFactory;
44 48
...@@ -52,8 +56,9 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -52,8 +56,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
52 @Component(immediate = true) 56 @Component(immediate = true)
53 @Service 57 @Service
54 public class VirtualNetworkManager 58 public class VirtualNetworkManager
55 - extends AbstractListenerManager<VirtualNetworkEvent, VirtualNetworkListener> 59 + extends AbstractListenerProviderRegistry<VirtualNetworkEvent, VirtualNetworkListener,
56 - implements VirtualNetworkService, VirtualNetworkAdminService { 60 + VirtualNetworkProvider, VirtualNetworkProviderService>
61 + implements VirtualNetworkService, VirtualNetworkAdminService, VirtualNetworkProviderRegistry {
57 62
58 private final Logger log = LoggerFactory.getLogger(getClass()); 63 private final Logger log = LoggerFactory.getLogger(getClass());
59 64
...@@ -67,7 +72,7 @@ public class VirtualNetworkManager ...@@ -67,7 +72,7 @@ public class VirtualNetworkManager
67 72
68 private VirtualNetworkStoreDelegate delegate = new InternalStoreDelegate(); 73 private VirtualNetworkStoreDelegate delegate = new InternalStoreDelegate();
69 74
70 - // TODO: figure out how to coordinate "implementation" of a virtual network 75 + // TODO: figure out how to coordinate "implementation" of a virtual network in a cluster
71 76
72 @Activate 77 @Activate
73 protected void activate() { 78 protected void activate() {
...@@ -191,6 +196,21 @@ public class VirtualNetworkManager ...@@ -191,6 +196,21 @@ public class VirtualNetworkManager
191 return null; 196 return null;
192 } 197 }
193 198
199 + @Override
200 + protected VirtualNetworkProviderService createProviderService(VirtualNetworkProvider provider) {
201 + return new InternalVirtualNetworkProviderService(provider);
202 + }
203 +
204 + // Service issued to registered virtual network providers so that they
205 + // can interact with the core.
206 + private class InternalVirtualNetworkProviderService
207 + extends AbstractProviderService<VirtualNetworkProvider>
208 + implements VirtualNetworkProviderService {
209 + InternalVirtualNetworkProviderService(VirtualNetworkProvider provider) {
210 + super(provider);
211 + }
212 + }
213 +
194 // Auxiliary store delegate to receive notification about changes in 214 // Auxiliary store delegate to receive notification about changes in
195 // the virtual network configuration store state - by the store itself. 215 // the virtual network configuration store state - by the store itself.
196 private class InternalStoreDelegate implements VirtualNetworkStoreDelegate { 216 private class InternalStoreDelegate implements VirtualNetworkStoreDelegate {
......