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