Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 1 | /* |
yoonseon | 9467211 | 2017-01-31 13:46:21 -0800 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 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.impl; |
| 17 | |
Harold Huang | 3fcf743 | 2017-05-16 16:21:08 +0800 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableSet; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 19 | import com.google.common.collect.Maps; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 20 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; |
| 23 | import org.apache.felix.scr.annotations.Reference; |
| 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 25 | import org.apache.felix.scr.annotations.Service; |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 26 | import org.onlab.osgi.DefaultServiceDirectory; |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 27 | import org.onlab.osgi.ServiceDirectory; |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 28 | import org.onlab.packet.IpAddress; |
| 29 | import org.onlab.packet.MacAddress; |
| 30 | import org.onlab.packet.VlanId; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 31 | import org.onosproject.core.ApplicationId; |
| 32 | import org.onosproject.core.CoreService; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 33 | import org.onosproject.incubator.net.tunnel.TunnelId; |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 34 | import org.onosproject.incubator.net.virtual.DefaultVirtualLink; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 35 | import org.onosproject.incubator.net.virtual.NetworkId; |
| 36 | import org.onosproject.incubator.net.virtual.TenantId; |
| 37 | import org.onosproject.incubator.net.virtual.VirtualDevice; |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 38 | import org.onosproject.incubator.net.virtual.VirtualHost; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 39 | import org.onosproject.incubator.net.virtual.VirtualLink; |
| 40 | import org.onosproject.incubator.net.virtual.VirtualNetwork; |
| 41 | import org.onosproject.incubator.net.virtual.VirtualNetworkAdminService; |
| 42 | import org.onosproject.incubator.net.virtual.VirtualNetworkEvent; |
| 43 | import org.onosproject.incubator.net.virtual.VirtualNetworkListener; |
| 44 | import org.onosproject.incubator.net.virtual.VirtualNetworkService; |
| 45 | import org.onosproject.incubator.net.virtual.VirtualNetworkStore; |
| 46 | import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate; |
| 47 | import org.onosproject.incubator.net.virtual.VirtualPort; |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 48 | import org.onosproject.incubator.net.virtual.VnetService; |
Claudine Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 49 | import org.onosproject.incubator.net.virtual.event.VirtualEvent; |
| 50 | import org.onosproject.incubator.net.virtual.event.VirtualListenerRegistryManager; |
yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 51 | import org.onosproject.incubator.net.virtual.provider.VirtualNetworkProvider; |
| 52 | import org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderRegistry; |
| 53 | import org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService; |
Harold Huang | 222c6ec | 2017-06-02 15:02:49 +0800 | [diff] [blame] | 54 | import org.onosproject.mastership.MastershipAdminService; |
Yoonseon Han | a578d76 | 2017-05-08 13:42:02 -0700 | [diff] [blame] | 55 | import org.onosproject.mastership.MastershipService; |
Harold Huang | 222c6ec | 2017-06-02 15:02:49 +0800 | [diff] [blame] | 56 | import org.onosproject.mastership.MastershipTermService; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 57 | import org.onosproject.net.ConnectPoint; |
| 58 | import org.onosproject.net.DeviceId; |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 59 | import org.onosproject.net.HostId; |
| 60 | import org.onosproject.net.HostLocation; |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 61 | import org.onosproject.net.Link; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 62 | import org.onosproject.net.PortNumber; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 63 | import org.onosproject.net.device.DeviceService; |
Claudine Chiu | 70222ad | 2016-11-17 22:29:20 -0500 | [diff] [blame] | 64 | import org.onosproject.net.flow.FlowRuleService; |
yoonseon | 86bebed | 2017-02-03 15:23:57 -0800 | [diff] [blame] | 65 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Claudine Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 66 | import org.onosproject.net.group.GroupService; |
Claudine Chiu | 30a8a2a | 2016-07-14 17:09:04 -0400 | [diff] [blame] | 67 | import org.onosproject.net.host.HostService; |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 68 | import org.onosproject.net.intent.IntentService; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 69 | import org.onosproject.net.link.LinkService; |
yoonseon | 9467211 | 2017-01-31 13:46:21 -0800 | [diff] [blame] | 70 | import org.onosproject.net.meter.MeterService; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 71 | import org.onosproject.net.packet.PacketService; |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 72 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; |
| 73 | import org.onosproject.net.provider.AbstractProviderService; |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 74 | import org.onosproject.net.topology.PathService; |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 75 | import org.onosproject.net.topology.TopologyService; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 76 | import org.slf4j.Logger; |
| 77 | import org.slf4j.LoggerFactory; |
| 78 | |
Harold Huang | 3fcf743 | 2017-05-16 16:21:08 +0800 | [diff] [blame] | 79 | import java.util.HashSet; |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 80 | import java.util.Map; |
Claudine Chiu | e7f6b91 | 2017-02-24 14:13:30 -0500 | [diff] [blame] | 81 | import java.util.Objects; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 82 | import java.util.Set; |
| 83 | |
| 84 | import static com.google.common.base.Preconditions.checkNotNull; |
| 85 | |
| 86 | /** |
| 87 | * Implementation of the virtual network service. |
| 88 | */ |
| 89 | @Component(immediate = true) |
| 90 | @Service |
| 91 | public class VirtualNetworkManager |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 92 | extends AbstractListenerProviderRegistry<VirtualNetworkEvent, |
| 93 | VirtualNetworkListener, VirtualNetworkProvider, VirtualNetworkProviderService> |
| 94 | implements VirtualNetworkService, VirtualNetworkAdminService, |
| 95 | VirtualNetworkProviderRegistry { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 96 | |
| 97 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 98 | |
| 99 | private static final String TENANT_NULL = "Tenant ID cannot be null"; |
| 100 | private static final String NETWORK_NULL = "Network ID cannot be null"; |
| 101 | private static final String DEVICE_NULL = "Device ID cannot be null"; |
| 102 | private static final String LINK_POINT_NULL = "Link end-point cannot be null"; |
| 103 | |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 104 | private static final String VIRTUAL_NETWORK_APP_ID_STRING = |
| 105 | "org.onosproject.virtual-network"; |
| 106 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 107 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 108 | protected VirtualNetworkStore store; |
| 109 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 110 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 111 | protected CoreService coreService; |
| 112 | |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 113 | private VirtualNetworkStoreDelegate delegate = this::post; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 114 | |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 115 | private ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 116 | private ApplicationId appId; |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 117 | |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 118 | // TODO: figure out how to coordinate "implementation" of a virtual network in a cluster |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 119 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 120 | /** |
| 121 | * Only used for Junit test methods outside of this package. |
| 122 | * |
| 123 | * @param store virtual network store |
| 124 | */ |
| 125 | public void setStore(VirtualNetworkStore store) { |
| 126 | this.store = store; |
| 127 | } |
| 128 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 129 | @Activate |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 130 | public void activate() { |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 131 | eventDispatcher.addSink(VirtualNetworkEvent.class, listenerRegistry); |
Claudine Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 132 | eventDispatcher.addSink(VirtualEvent.class, |
| 133 | VirtualListenerRegistryManager.getInstance()); |
Yoonseon Han | b14461b | 2017-03-07 14:08:01 +0900 | [diff] [blame] | 134 | store.setDelegate(delegate); |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 135 | appId = coreService.registerApplication(VIRTUAL_NETWORK_APP_ID_STRING); |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 136 | log.info("Started"); |
| 137 | } |
| 138 | |
| 139 | @Deactivate |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 140 | public void deactivate() { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 141 | store.unsetDelegate(delegate); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 142 | eventDispatcher.removeSink(VirtualNetworkEvent.class); |
Claudine Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 143 | eventDispatcher.removeSink(VirtualEvent.class); |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 144 | log.info("Stopped"); |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | public void registerTenantId(TenantId tenantId) { |
| 149 | checkNotNull(tenantId, TENANT_NULL); |
| 150 | store.addTenantId(tenantId); |
| 151 | } |
| 152 | |
| 153 | @Override |
| 154 | public void unregisterTenantId(TenantId tenantId) { |
| 155 | checkNotNull(tenantId, TENANT_NULL); |
| 156 | store.removeTenantId(tenantId); |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public Set<TenantId> getTenantIds() { |
| 161 | return store.getTenantIds(); |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public VirtualNetwork createVirtualNetwork(TenantId tenantId) { |
| 166 | checkNotNull(tenantId, TENANT_NULL); |
| 167 | return store.addNetwork(tenantId); |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public void removeVirtualNetwork(NetworkId networkId) { |
| 172 | checkNotNull(networkId, NETWORK_NULL); |
| 173 | store.removeNetwork(networkId); |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public VirtualDevice createVirtualDevice(NetworkId networkId, DeviceId deviceId) { |
| 178 | checkNotNull(networkId, NETWORK_NULL); |
| 179 | checkNotNull(deviceId, DEVICE_NULL); |
| 180 | return store.addDevice(networkId, deviceId); |
| 181 | } |
| 182 | |
| 183 | @Override |
| 184 | public void removeVirtualDevice(NetworkId networkId, DeviceId deviceId) { |
| 185 | checkNotNull(networkId, NETWORK_NULL); |
| 186 | checkNotNull(deviceId, DEVICE_NULL); |
| 187 | store.removeDevice(networkId, deviceId); |
| 188 | } |
| 189 | |
| 190 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 191 | public VirtualHost createVirtualHost(NetworkId networkId, HostId hostId, |
| 192 | MacAddress mac, VlanId vlan, |
| 193 | HostLocation location, Set<IpAddress> ips) { |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 194 | checkNotNull(networkId, NETWORK_NULL); |
| 195 | checkNotNull(hostId, DEVICE_NULL); |
| 196 | return store.addHost(networkId, hostId, mac, vlan, location, ips); |
| 197 | } |
| 198 | |
| 199 | @Override |
| 200 | public void removeVirtualHost(NetworkId networkId, HostId hostId) { |
| 201 | checkNotNull(networkId, NETWORK_NULL); |
| 202 | checkNotNull(hostId, DEVICE_NULL); |
| 203 | store.removeHost(networkId, hostId); |
| 204 | } |
| 205 | |
| 206 | @Override |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 207 | public VirtualLink createVirtualLink(NetworkId networkId, |
Brian Stanke | 9a10897 | 2016-04-11 15:25:17 -0400 | [diff] [blame] | 208 | ConnectPoint src, ConnectPoint dst) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 209 | checkNotNull(networkId, NETWORK_NULL); |
| 210 | checkNotNull(src, LINK_POINT_NULL); |
| 211 | checkNotNull(dst, LINK_POINT_NULL); |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 212 | ConnectPoint physicalSrc = mapVirtualToPhysicalPort(networkId, src); |
| 213 | checkNotNull(physicalSrc, LINK_POINT_NULL); |
| 214 | ConnectPoint physicalDst = mapVirtualToPhysicalPort(networkId, dst); |
| 215 | checkNotNull(physicalDst, LINK_POINT_NULL); |
| 216 | |
| 217 | VirtualNetworkProvider provider = getProvider(DefaultVirtualLink.PID); |
| 218 | Link.State state = Link.State.INACTIVE; |
| 219 | if (provider != null) { |
| 220 | boolean traversable = provider.isTraversable(physicalSrc, physicalDst); |
| 221 | state = traversable ? Link.State.ACTIVE : Link.State.INACTIVE; |
| 222 | } |
| 223 | return store.addLink(networkId, src, dst, state, null); |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Maps the virtual connect point to a physical connect point. |
| 228 | * |
| 229 | * @param networkId network identifier |
| 230 | * @param virtualCp virtual connect point |
| 231 | * @return physical connect point |
| 232 | */ |
| 233 | private ConnectPoint mapVirtualToPhysicalPort(NetworkId networkId, |
| 234 | ConnectPoint virtualCp) { |
| 235 | Set<VirtualPort> ports = store.getPorts(networkId, virtualCp.deviceId()); |
| 236 | for (VirtualPort port : ports) { |
| 237 | if (port.number().equals(virtualCp.port())) { |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 238 | return new ConnectPoint(port.realizedBy().deviceId(), |
| 239 | port.realizedBy().port()); |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | return null; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 245 | /** |
| 246 | * Maps the physical connect point to a virtual connect point. |
| 247 | * |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 248 | * @param networkId network identifier |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 249 | * @param physicalCp physical connect point |
| 250 | * @return virtual connect point |
| 251 | */ |
| 252 | private ConnectPoint mapPhysicalToVirtualToPort(NetworkId networkId, |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 253 | ConnectPoint physicalCp) { |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 254 | Set<VirtualPort> ports = store.getPorts(networkId, null); |
| 255 | for (VirtualPort port : ports) { |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 256 | if (port.realizedBy().deviceId().equals(physicalCp.elementId()) && |
| 257 | port.realizedBy().port().equals(physicalCp.port())) { |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 258 | return new ConnectPoint(port.element().id(), port.number()); |
| 259 | } |
| 260 | } |
| 261 | return null; |
| 262 | } |
| 263 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 264 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 265 | public void removeVirtualLink(NetworkId networkId, ConnectPoint src, |
| 266 | ConnectPoint dst) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 267 | checkNotNull(networkId, NETWORK_NULL); |
| 268 | checkNotNull(src, LINK_POINT_NULL); |
| 269 | checkNotNull(dst, LINK_POINT_NULL); |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 270 | store.removeLink(networkId, src, dst); |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | @Override |
| 274 | public VirtualPort createVirtualPort(NetworkId networkId, DeviceId deviceId, |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 275 | PortNumber portNumber, ConnectPoint realizedBy) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 276 | checkNotNull(networkId, NETWORK_NULL); |
| 277 | checkNotNull(deviceId, DEVICE_NULL); |
| 278 | checkNotNull(portNumber, "Port description cannot be null"); |
| 279 | return store.addPort(networkId, deviceId, portNumber, realizedBy); |
| 280 | } |
| 281 | |
| 282 | @Override |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 283 | public void bindVirtualPort(NetworkId networkId, DeviceId deviceId, |
| 284 | PortNumber portNumber, ConnectPoint realizedBy) { |
| 285 | checkNotNull(networkId, NETWORK_NULL); |
| 286 | checkNotNull(deviceId, DEVICE_NULL); |
| 287 | checkNotNull(portNumber, "Port description cannot be null"); |
| 288 | checkNotNull(realizedBy, "Physical port description cannot be null"); |
| 289 | |
| 290 | store.bindPort(networkId, deviceId, portNumber, realizedBy); |
| 291 | } |
| 292 | |
| 293 | @Override |
Claudine Chiu | 579969d | 2017-10-06 14:32:18 -0400 | [diff] [blame] | 294 | public void updatePortState(NetworkId networkId, DeviceId deviceId, |
| 295 | PortNumber portNumber, boolean isEnabled) { |
| 296 | checkNotNull(networkId, NETWORK_NULL); |
| 297 | checkNotNull(deviceId, DEVICE_NULL); |
| 298 | checkNotNull(portNumber, "Port description cannot be null"); |
| 299 | |
| 300 | store.updatePortState(networkId, deviceId, portNumber, isEnabled); |
| 301 | } |
| 302 | |
| 303 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 304 | public void removeVirtualPort(NetworkId networkId, DeviceId deviceId, |
| 305 | PortNumber portNumber) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 306 | checkNotNull(networkId, NETWORK_NULL); |
| 307 | checkNotNull(deviceId, DEVICE_NULL); |
| 308 | checkNotNull(portNumber, "Port number cannot be null"); |
| 309 | store.removePort(networkId, deviceId, portNumber); |
| 310 | } |
| 311 | |
| 312 | @Override |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 313 | public ServiceDirectory getServiceDirectory() { |
| 314 | return serviceDirectory; |
| 315 | } |
| 316 | |
| 317 | @Override |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 318 | public Set<VirtualNetwork> getVirtualNetworks(TenantId tenantId) { |
| 319 | checkNotNull(tenantId, TENANT_NULL); |
| 320 | return store.getNetworks(tenantId); |
| 321 | } |
| 322 | |
Jovana Vuleta | c884b69 | 2017-11-28 16:52:35 +0100 | [diff] [blame] | 323 | @Override |
| 324 | public VirtualNetwork getVirtualNetwork(NetworkId networkId) { |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 325 | checkNotNull(networkId, NETWORK_NULL); |
| 326 | return store.getNetwork(networkId); |
| 327 | } |
| 328 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 329 | @Override |
Jovana Vuleta | c884b69 | 2017-11-28 16:52:35 +0100 | [diff] [blame] | 330 | public TenantId getTenantId(NetworkId networkId) { |
| 331 | VirtualNetwork virtualNetwork = getVirtualNetwork(networkId); |
| 332 | checkNotNull(virtualNetwork, "The network does not exist."); |
| 333 | return virtualNetwork.tenantId(); |
| 334 | } |
| 335 | |
| 336 | @Override |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 337 | public Set<VirtualDevice> getVirtualDevices(NetworkId networkId) { |
| 338 | checkNotNull(networkId, NETWORK_NULL); |
| 339 | return store.getDevices(networkId); |
| 340 | } |
| 341 | |
| 342 | @Override |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 343 | public Set<VirtualHost> getVirtualHosts(NetworkId networkId) { |
| 344 | checkNotNull(networkId, NETWORK_NULL); |
| 345 | return store.getHosts(networkId); |
| 346 | } |
| 347 | |
| 348 | @Override |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 349 | public Set<VirtualLink> getVirtualLinks(NetworkId networkId) { |
| 350 | checkNotNull(networkId, NETWORK_NULL); |
| 351 | return store.getLinks(networkId); |
| 352 | } |
| 353 | |
| 354 | @Override |
| 355 | public Set<VirtualPort> getVirtualPorts(NetworkId networkId, DeviceId deviceId) { |
| 356 | checkNotNull(networkId, NETWORK_NULL); |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 357 | return store.getPorts(networkId, deviceId); |
| 358 | } |
| 359 | |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 360 | @Override |
Harold Huang | 3fcf743 | 2017-05-16 16:21:08 +0800 | [diff] [blame] | 361 | public Set<DeviceId> getPhysicalDevices(NetworkId networkId, DeviceId deviceId) { |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 362 | checkNotNull(networkId, "Network ID cannot be null"); |
Harold Huang | 3fcf743 | 2017-05-16 16:21:08 +0800 | [diff] [blame] | 363 | checkNotNull(deviceId, "Virtual device ID cannot be null"); |
| 364 | Set<VirtualPort> virtualPortSet = getVirtualPorts(networkId, deviceId); |
| 365 | Set<DeviceId> physicalDeviceSet = new HashSet<>(); |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 366 | |
| 367 | virtualPortSet.forEach(virtualPort -> { |
| 368 | if (virtualPort.realizedBy() != null) { |
| 369 | physicalDeviceSet.add(virtualPort.realizedBy().deviceId()); |
| 370 | } |
| 371 | }); |
| 372 | |
Harold Huang | 3fcf743 | 2017-05-16 16:21:08 +0800 | [diff] [blame] | 373 | return ImmutableSet.copyOf(physicalDeviceSet); |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 376 | private final Map<ServiceKey, VnetService> networkServices = Maps.newConcurrentMap(); |
| 377 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 378 | @Override |
Yoonseon Han | b14461b | 2017-03-07 14:08:01 +0900 | [diff] [blame] | 379 | @SuppressWarnings("unchecked") |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 380 | public <T> T get(NetworkId networkId, Class<T> serviceClass) { |
| 381 | checkNotNull(networkId, NETWORK_NULL); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 382 | ServiceKey serviceKey = networkServiceKey(networkId, serviceClass); |
| 383 | VnetService service = lookup(serviceKey); |
| 384 | if (service == null) { |
| 385 | service = create(serviceKey); |
| 386 | } |
| 387 | return (T) service; |
| 388 | } |
| 389 | |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 390 | @Override |
| 391 | public ApplicationId getVirtualNetworkApplicationId(NetworkId networkId) { |
| 392 | return appId; |
| 393 | } |
| 394 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 395 | /** |
| 396 | * Returns the Vnet service matching the service key. |
| 397 | * |
| 398 | * @param serviceKey service key |
| 399 | * @return vnet service |
| 400 | */ |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 401 | private VnetService lookup(ServiceKey serviceKey) { |
| 402 | return networkServices.get(serviceKey); |
| 403 | } |
| 404 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 405 | /** |
| 406 | * Creates a new service key using the specified network identifier and service class. |
| 407 | * |
| 408 | * @param networkId network identifier |
| 409 | * @param serviceClass service class |
| 410 | * @param <T> type of service |
| 411 | * @return service key |
| 412 | */ |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 413 | private <T> ServiceKey networkServiceKey(NetworkId networkId, Class<T> serviceClass) { |
| 414 | return new ServiceKey(networkId, serviceClass); |
| 415 | } |
| 416 | |
| 417 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 418 | /** |
| 419 | * Create a new vnet service instance. |
| 420 | * |
| 421 | * @param serviceKey service key |
| 422 | * @return vnet service |
| 423 | */ |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 424 | private VnetService create(ServiceKey serviceKey) { |
| 425 | VirtualNetwork network = getVirtualNetwork(serviceKey.networkId()); |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 426 | checkNotNull(network, NETWORK_NULL); |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 427 | |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 428 | VnetService service; |
| 429 | if (serviceKey.serviceClass.equals(DeviceService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 430 | service = new VirtualNetworkDeviceManager(this, network.id()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 431 | } else if (serviceKey.serviceClass.equals(LinkService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 432 | service = new VirtualNetworkLinkManager(this, network.id()); |
Brian Stanke | 8e9f8d1 | 2016-06-08 14:48:33 -0400 | [diff] [blame] | 433 | } else if (serviceKey.serviceClass.equals(TopologyService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 434 | service = new VirtualNetworkTopologyManager(this, network.id()); |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 435 | } else if (serviceKey.serviceClass.equals(IntentService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 436 | service = new VirtualNetworkIntentManager(this, network.id()); |
Claudine Chiu | 30a8a2a | 2016-07-14 17:09:04 -0400 | [diff] [blame] | 437 | } else if (serviceKey.serviceClass.equals(HostService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 438 | service = new VirtualNetworkHostManager(this, network.id()); |
Claudine Chiu | 45920dd | 2016-07-28 19:19:46 +0000 | [diff] [blame] | 439 | } else if (serviceKey.serviceClass.equals(PathService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 440 | service = new VirtualNetworkPathManager(this, network.id()); |
Claudine Chiu | 70222ad | 2016-11-17 22:29:20 -0500 | [diff] [blame] | 441 | } else if (serviceKey.serviceClass.equals(FlowRuleService.class)) { |
yoonseon | c6a6927 | 2017-01-12 18:22:20 -0800 | [diff] [blame] | 442 | service = new VirtualNetworkFlowRuleManager(this, network.id()); |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 443 | } else if (serviceKey.serviceClass.equals(PacketService.class)) { |
| 444 | service = new VirtualNetworkPacketManager(this, network.id()); |
yoonseon | dc3210d | 2017-01-25 16:03:10 -0800 | [diff] [blame] | 445 | } else if (serviceKey.serviceClass.equals(GroupService.class)) { |
| 446 | service = new VirtualNetworkGroupManager(this, network.id()); |
yoonseon | 9467211 | 2017-01-31 13:46:21 -0800 | [diff] [blame] | 447 | } else if (serviceKey.serviceClass.equals(MeterService.class)) { |
| 448 | service = new VirtualNetworkMeterManager(this, network.id()); |
yoonseon | 86bebed | 2017-02-03 15:23:57 -0800 | [diff] [blame] | 449 | } else if (serviceKey.serviceClass.equals(FlowObjectiveService.class)) { |
| 450 | service = new VirtualNetworkFlowObjectiveManager(this, network.id()); |
Harold Huang | 222c6ec | 2017-06-02 15:02:49 +0800 | [diff] [blame] | 451 | } else if (serviceKey.serviceClass.equals(MastershipService.class) || |
| 452 | serviceKey.serviceClass.equals(MastershipAdminService.class) || |
| 453 | serviceKey.serviceClass.equals(MastershipTermService.class)) { |
Yoonseon Han | a578d76 | 2017-05-08 13:42:02 -0700 | [diff] [blame] | 454 | service = new VirtualNetworkMastershipManager(this, network.id()); |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 455 | } else { |
| 456 | return null; |
| 457 | } |
| 458 | networkServices.put(serviceKey, service); |
| 459 | return service; |
| 460 | } |
| 461 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 462 | /** |
| 463 | * Service key class. |
| 464 | */ |
Claudine Chiu | 9a18f49 | 2017-02-27 15:57:06 -0500 | [diff] [blame] | 465 | private static class ServiceKey { |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 466 | final NetworkId networkId; |
| 467 | final Class serviceClass; |
| 468 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 469 | /** |
| 470 | * Constructor for service key. |
| 471 | * |
| 472 | * @param networkId network identifier |
| 473 | * @param serviceClass service class |
| 474 | */ |
Yoonseon Han | b14461b | 2017-03-07 14:08:01 +0900 | [diff] [blame] | 475 | ServiceKey(NetworkId networkId, Class serviceClass) { |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 476 | |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 477 | checkNotNull(networkId, NETWORK_NULL); |
| 478 | this.networkId = networkId; |
| 479 | this.serviceClass = serviceClass; |
| 480 | } |
| 481 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 482 | /** |
| 483 | * Returns the network identifier. |
| 484 | * |
| 485 | * @return network identifier |
| 486 | */ |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 487 | public NetworkId networkId() { |
| 488 | return networkId; |
| 489 | } |
| 490 | |
Brian Stanke | 11f6d53 | 2016-07-05 16:17:59 -0400 | [diff] [blame] | 491 | /** |
| 492 | * Returns the service class. |
| 493 | * |
| 494 | * @return service class |
| 495 | */ |
Brian Stanke | 8691428 | 2016-05-25 15:36:50 -0400 | [diff] [blame] | 496 | public Class serviceClass() { |
| 497 | return serviceClass; |
| 498 | } |
Claudine Chiu | e7f6b91 | 2017-02-24 14:13:30 -0500 | [diff] [blame] | 499 | |
| 500 | @Override |
| 501 | public int hashCode() { |
| 502 | return Objects.hash(networkId, serviceClass); |
| 503 | } |
| 504 | |
| 505 | @Override |
| 506 | public boolean equals(Object obj) { |
| 507 | if (this == obj) { |
| 508 | return true; |
| 509 | } |
| 510 | if (obj instanceof ServiceKey) { |
| 511 | ServiceKey that = (ServiceKey) obj; |
| 512 | return Objects.equals(this.networkId, that.networkId) && |
| 513 | Objects.equals(this.serviceClass, that.serviceClass); |
| 514 | } |
| 515 | return false; |
| 516 | } |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 519 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 520 | protected VirtualNetworkProviderService |
| 521 | createProviderService(VirtualNetworkProvider provider) { |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 522 | return new InternalVirtualNetworkProviderService(provider); |
| 523 | } |
| 524 | |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 525 | /** |
| 526 | * Service issued to registered virtual network providers so that they |
| 527 | * can interact with the core. |
| 528 | */ |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 529 | private class InternalVirtualNetworkProviderService |
| 530 | extends AbstractProviderService<VirtualNetworkProvider> |
| 531 | implements VirtualNetworkProviderService { |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 532 | /** |
| 533 | * Constructor. |
| 534 | * @param provider virtual network provider |
| 535 | */ |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 536 | InternalVirtualNetworkProviderService(VirtualNetworkProvider provider) { |
| 537 | super(provider); |
| 538 | } |
Brian Stanke | 4d57988 | 2016-04-22 13:28:46 -0400 | [diff] [blame] | 539 | |
| 540 | @Override |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 541 | public void topologyChanged(Set<Set<ConnectPoint>> clusters) { |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 542 | Set<TenantId> tenantIds = getTenantIds(); |
| 543 | tenantIds.forEach(tenantId -> { |
| 544 | Set<VirtualNetwork> virtualNetworks = getVirtualNetworks(tenantId); |
| 545 | |
| 546 | virtualNetworks.forEach(virtualNetwork -> { |
| 547 | Set<VirtualLink> virtualLinks = getVirtualLinks(virtualNetwork.id()); |
| 548 | |
| 549 | virtualLinks.forEach(virtualLink -> { |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 550 | if (isVirtualLinkInCluster(virtualNetwork.id(), |
| 551 | virtualLink, clusters)) { |
| 552 | store.updateLink(virtualLink, virtualLink.tunnelId(), |
| 553 | Link.State.ACTIVE); |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 554 | } else { |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 555 | store.updateLink(virtualLink, virtualLink.tunnelId(), |
| 556 | Link.State.INACTIVE); |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 557 | } |
| 558 | }); |
| 559 | }); |
| 560 | }); |
| 561 | } |
| 562 | |
| 563 | /** |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 564 | * Determines if the virtual link (both source and destination connect point) |
| 565 | * is in a cluster. |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 566 | * |
| 567 | * @param networkId virtual network identifier |
| 568 | * @param virtualLink virtual link |
| 569 | * @param clusters topology clusters |
| 570 | * @return true if the virtual link is in a cluster. |
| 571 | */ |
| 572 | private boolean isVirtualLinkInCluster(NetworkId networkId, VirtualLink virtualLink, |
| 573 | Set<Set<ConnectPoint>> clusters) { |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 574 | ConnectPoint srcPhysicalCp = |
| 575 | mapVirtualToPhysicalPort(networkId, virtualLink.src()); |
| 576 | ConnectPoint dstPhysicalCp = |
| 577 | mapVirtualToPhysicalPort(networkId, virtualLink.dst()); |
Brian Stanke | fb61df4 | 2016-07-25 11:47:51 -0400 | [diff] [blame] | 578 | |
| 579 | final boolean[] foundSrc = {false}; |
| 580 | final boolean[] foundDst = {false}; |
| 581 | clusters.forEach(connectPoints -> { |
| 582 | connectPoints.forEach(connectPoint -> { |
| 583 | if (connectPoint.equals(srcPhysicalCp)) { |
| 584 | foundSrc[0] = true; |
| 585 | } else if (connectPoint.equals(dstPhysicalCp)) { |
| 586 | foundDst[0] = true; |
| 587 | } |
| 588 | }); |
| 589 | if (foundSrc[0] && foundDst[0]) { |
| 590 | return; |
| 591 | } |
| 592 | }); |
| 593 | return foundSrc[0] && foundDst[0]; |
| 594 | } |
| 595 | |
| 596 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 597 | public void tunnelUp(NetworkId networkId, ConnectPoint src, |
| 598 | ConnectPoint dst, TunnelId tunnelId) { |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 599 | ConnectPoint srcVirtualCp = mapPhysicalToVirtualToPort(networkId, src); |
| 600 | ConnectPoint dstVirtualCp = mapPhysicalToVirtualToPort(networkId, dst); |
| 601 | if ((srcVirtualCp == null) || (dstVirtualCp == null)) { |
| 602 | log.error("Src or dst virtual connection point was not found."); |
| 603 | } |
| 604 | |
| 605 | VirtualLink virtualLink = store.getLink(networkId, srcVirtualCp, dstVirtualCp); |
| 606 | if (virtualLink != null) { |
| 607 | store.updateLink(virtualLink, tunnelId, Link.State.ACTIVE); |
| 608 | } |
Brian Stanke | 4d57988 | 2016-04-22 13:28:46 -0400 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | @Override |
yoonseon | 214963b | 2016-11-21 15:41:07 -0800 | [diff] [blame] | 612 | public void tunnelDown(NetworkId networkId, ConnectPoint src, |
| 613 | ConnectPoint dst, TunnelId tunnelId) { |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 614 | ConnectPoint srcVirtualCp = mapPhysicalToVirtualToPort(networkId, src); |
| 615 | ConnectPoint dstVirtualCp = mapPhysicalToVirtualToPort(networkId, dst); |
| 616 | if ((srcVirtualCp == null) || (dstVirtualCp == null)) { |
| 617 | log.error("Src or dst virtual connection point was not found."); |
| 618 | } |
Brian Stanke | 4d57988 | 2016-04-22 13:28:46 -0400 | [diff] [blame] | 619 | |
Brian Stanke | 612cebf | 2016-05-02 10:21:33 -0400 | [diff] [blame] | 620 | VirtualLink virtualLink = store.getLink(networkId, srcVirtualCp, dstVirtualCp); |
| 621 | if (virtualLink != null) { |
| 622 | store.updateLink(virtualLink, tunnelId, Link.State.INACTIVE); |
| 623 | } |
Brian Stanke | 4d57988 | 2016-04-22 13:28:46 -0400 | [diff] [blame] | 624 | } |
Thomas Vachuska | 3d62fd7 | 2015-09-25 14:58:13 -0700 | [diff] [blame] | 625 | } |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 626 | } |