2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.vpp.iface;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import java.util.concurrent.ExecutionException;
14 import java.util.concurrent.ExecutorService;
15 import com.google.common.base.Optional;
16 import com.google.common.base.Preconditions;
17 import com.google.common.base.Strings;
18 import com.google.common.eventbus.Subscribe;
19 import com.google.common.util.concurrent.AsyncFunction;
20 import com.google.common.util.concurrent.CheckedFuture;
21 import com.google.common.util.concurrent.Futures;
22 import com.google.common.util.concurrent.ListenableFuture;
23 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
24 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
25 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
26 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
27 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.ConfigCommand;
28 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.TapPortCommand;
29 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.VhostUserCommand;
30 import org.opendaylight.groupbasedpolicy.renderer.vpp.commands.VhostUserCommand.VhostUserCommandBuilder;
31 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.NodeOperEvent;
32 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.VppEndpointConfEvent;
33 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.General.Operations;
34 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProvider;
35 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.LocationType;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.location.type.ExternalLocationCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.location.type.ExternalLocationCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.endpoints.AddressEndpointWithLocation;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.vpp.endpoint.InterfaceTypeChoice;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.vpp.endpoint._interface.type.choice.TapCase;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.vpp.endpoint._interface.type.choice.VhostUserCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VhostUserRole;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.L2;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.L2Builder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.Interconnection;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.BridgeBased;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.BridgeBasedBuilder;
52 import org.opendaylight.yangtools.yang.binding.DataObject;
53 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
57 public class InterfaceManager implements AutoCloseable {
59 private static final Logger LOG = LoggerFactory.getLogger(InterfaceManager.class);
60 private final MountedDataBrokerProvider mountDataProvider;
61 private final VppEndpointLocationProvider vppEndpointLocationProvider;
62 private final ExecutorService netconfWorker;
64 public InterfaceManager(@Nonnull MountedDataBrokerProvider mountDataProvider, @Nonnull DataBroker dataProvider,
65 @Nonnull ExecutorService netconfWorker) {
66 this.mountDataProvider = Preconditions.checkNotNull(mountDataProvider);
67 this.netconfWorker = Preconditions.checkNotNull(netconfWorker);
68 this.vppEndpointLocationProvider = new VppEndpointLocationProvider(dataProvider);
72 @SuppressWarnings("OptionalGetWithoutIsPresent")
73 public synchronized void vppEndpointChanged(VppEndpointConfEvent event) {
75 switch (event.getDtoModificationType()) {
77 vppEndpointCreated(event.getAfter().get()).get();
81 vppEndpointUpdated(event.getBefore().get(), event.getAfter().get()).get();
84 vppEndpointDeleted(event.getBefore().get()).get();
87 } catch (InterruptedException | ExecutionException e) {
88 LOG.error("Failed to update Vpp Endpoint. {}", event, e);
92 private ListenableFuture<Void> vppEndpointCreated(VppEndpoint vppEndpoint) {
93 InterfaceTypeChoice interfaceTypeChoice = vppEndpoint.getInterfaceTypeChoice();
94 Optional<ConfigCommand> potentialIfaceCommand = Optional.absent();
95 if (interfaceTypeChoice instanceof VhostUserCase) {
96 potentialIfaceCommand = createInterfaceWithoutBdCommand(vppEndpoint, Operations.PUT);
97 } else if (interfaceTypeChoice instanceof TapCase) {
98 potentialIfaceCommand = createTapInterfaceWithoutBdCommand(vppEndpoint, Operations.PUT);
101 if (!potentialIfaceCommand.isPresent()) {
102 LOG.debug("Interface/PUT command was not created for VppEndpoint point {}", vppEndpoint);
103 return Futures.immediateFuture(null);
105 ConfigCommand ifaceWithoutBdCommand = potentialIfaceCommand.get();
106 InstanceIdentifier<?> vppNodeIid = vppEndpoint.getVppNodePath();
107 Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
108 if (!potentialVppDataProvider.isPresent()) {
109 LOG.debug("Cannot get data broker for mount point {}", vppNodeIid);
110 return Futures.immediateFuture(null);
112 DataBroker vppDataBroker = potentialVppDataProvider.get();
113 return createInterfaceOnVpp(ifaceWithoutBdCommand, vppDataBroker, vppEndpoint, vppNodeIid);
116 private ListenableFuture<Void> createInterfaceOnVpp(ConfigCommand createIfaceWithoutBdCommand, DataBroker vppDataBroker,
117 VppEndpoint vppEndpoint, InstanceIdentifier<?> vppNodeIid) {
118 final ReadWriteTransaction rwTx = vppDataBroker.newReadWriteTransaction();
119 createIfaceWithoutBdCommand.execute(rwTx);
120 return Futures.transform(rwTx.submit(), new AsyncFunction<Void, Void>() {
123 public ListenableFuture<Void> apply(@Nonnull Void input) {
124 LOG.debug("Create interface on VPP command was successful. VPP: {} Command: {}", vppNodeIid,
125 createIfaceWithoutBdCommand);
126 return vppEndpointLocationProvider.createLocationForVppEndpoint(vppEndpoint);
131 private ListenableFuture<Void> vppEndpointUpdated(@Nonnull final VppEndpoint oldVppEndpoint,
132 @Nonnull final VppEndpoint newVppEndpoint)
133 throws ExecutionException, InterruptedException {
134 if(!oldVppEndpoint.equals(newVppEndpoint)) {
135 LOG.debug("Updating vpp endpoint, old EP: {} new EP: {}", oldVppEndpoint, newVppEndpoint);
136 return Futures.transform(vppEndpointDeleted(oldVppEndpoint), new AsyncFunction<Void, Void>() {
138 public ListenableFuture<Void> apply(@Nonnull Void input) throws Exception {
139 return vppEndpointCreated(newVppEndpoint);
143 LOG.debug("Update skipped, provided before/after vpp endpoints are equal");
144 return Futures.immediateFuture(null);
147 private ListenableFuture<Void> vppEndpointDeleted(@Nonnull VppEndpoint vppEndpoint) {
148 InterfaceTypeChoice interfaceTypeChoice = vppEndpoint.getInterfaceTypeChoice();
149 Optional<ConfigCommand> potentialIfaceCommand = Optional.absent();
150 if (interfaceTypeChoice instanceof VhostUserCase) {
151 potentialIfaceCommand = createInterfaceWithoutBdCommand(vppEndpoint, Operations.DELETE);
152 } else if (interfaceTypeChoice instanceof TapCase) {
153 potentialIfaceCommand = createTapInterfaceWithoutBdCommand(vppEndpoint, Operations.DELETE);
156 if (!potentialIfaceCommand.isPresent()) {
157 LOG.debug("Interface/DELETE command was not created for VppEndpoint point {}", vppEndpoint);
158 return Futures.immediateFuture(null);
160 ConfigCommand ifaceWithoutBdCommand = potentialIfaceCommand.get();
161 InstanceIdentifier<?> vppNodeIid = vppEndpoint.getVppNodePath();
162 Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
163 if (!potentialVppDataProvider.isPresent()) {
164 LOG.debug("Cannot get data broker for mount point {}", vppNodeIid);
165 return Futures.immediateFuture(null);
167 DataBroker vppDataBroker = potentialVppDataProvider.get();
168 return deleteIfaceOnVpp(ifaceWithoutBdCommand, vppDataBroker, vppEndpoint, vppNodeIid);
171 private ListenableFuture<Void> deleteIfaceOnVpp(ConfigCommand deleteIfaceWithoutBdCommand,
172 DataBroker vppDataBroker, VppEndpoint vppEndpoint, InstanceIdentifier<?> vppNodeIid) {
173 ReadWriteTransaction rwTx = vppDataBroker.newReadWriteTransaction();
174 deleteIfaceWithoutBdCommand.execute(rwTx);
176 return Futures.transform(rwTx.submit(), new AsyncFunction<Void, Void>() {
179 public ListenableFuture<Void> apply(Void input) {
180 LOG.debug("Delete interface on VPP command was successful: VPP: {} Command: {}", vppNodeIid,
181 deleteIfaceWithoutBdCommand);
182 return vppEndpointLocationProvider.deleteLocationForVppEndpoint(vppEndpoint);
188 public synchronized void vppNodeChanged(NodeOperEvent event) {
189 switch (event.getDtoModificationType()) {
191 if (event.isAfterConnected()) {
192 // TODO read VppEndpoints or cache them during vppEndpointChanged()
196 if (!event.isBeforeConnected() && event.isAfterConnected()) {
197 // TODO reconciliation - diff between disconnected snapshot and current snapshot
201 if (event.isBeforeConnected()) {
202 // TODO we could do snapshot of VppEndpoints
203 // which can be used for reconciliation
209 private static Optional<ConfigCommand> createInterfaceWithoutBdCommand(@Nonnull VppEndpoint vppEp,
210 @Nonnull Operations operations) {
211 if (!hasNodeAndInterface(vppEp)) {
212 LOG.debug("Interface command is not created for {}", vppEp);
213 return Optional.absent();
215 VhostUserCommandBuilder builder = VhostUserCommand.builder();
216 builder.setName(vppEp.getVppInterfaceName());
217 InterfaceTypeChoice interfaceTypeChoice = vppEp.getInterfaceTypeChoice();
218 if (interfaceTypeChoice instanceof VhostUserCase) {
219 VhostUserCase vhostUserIface = (VhostUserCase) interfaceTypeChoice;
220 String socket = vhostUserIface.getSocket();
221 if (Strings.isNullOrEmpty(socket)) {
222 LOG.debug("Vhost user interface command is not created because socket is missing. {}", vppEp);
223 return Optional.absent();
225 builder.setSocket(socket);
226 builder.setRole(VhostUserRole.Client);
228 VhostUserCommand vhostUserCommand =
229 builder.setOperation(operations).setDescription(vppEp.getDescription()).build();
230 return Optional.of(vhostUserCommand);
233 private static Optional<ConfigCommand> createTapInterfaceWithoutBdCommand(@Nonnull VppEndpoint vppEp,
234 @Nonnull Operations operation) {
235 if (!hasNodeAndInterface(vppEp)) {
236 LOG.debug("Interface command is not created for {}", vppEp);
237 return Optional.absent();
239 TapPortCommand.TapPortCommandBuilder builder = TapPortCommand.builder();
240 InterfaceTypeChoice interfaceTypeChoice = vppEp.getInterfaceTypeChoice();
241 if (interfaceTypeChoice instanceof TapCase) {
242 TapCase tapIface = (TapCase) interfaceTypeChoice;
243 String name = tapIface.getName();
244 if (Strings.isNullOrEmpty(name)) {
245 LOG.debug("Tap interface command is not created because name is missing. {}", vppEp);
246 return Optional.absent();
248 builder.setTapName(name);
249 builder.setPhysAddress(tapIface.getPhysicalAddress());
251 TapPortCommand tapPortCommand = builder
252 .setOperation(operation)
253 .setDescription(vppEp.getDescription())
254 .setInterfaceName(vppEp.getVppInterfaceName())
256 return Optional.of(tapPortCommand);
260 * Adds bridge domain to an interface if the interface exist.<br>
261 * It rewrites bridge domain in case it already exist.<br>
262 * {@link VppEndpointLocationProvider#VPP_ENDPOINT_LOCATION_PROVIDER} will update location
263 * when the interface is created successfully.<br>
264 * If the interface does not exist or other problems occur {@link ListenableFuture} will fail
265 * as {@link Futures#immediateFailedFuture(Throwable)} with {@link Exception}
266 * containing message in {@link Exception#getMessage()}
268 * @param bridgeDomainName bridge domain
269 * @param addrEpWithLoc {@link AddressEndpointWithLocation} containing
270 * {@link ExternalLocationCase} where
271 * {@link ExternalLocationCase#getExternalNodeMountPoint()} MUST NOT be {@code null}
272 * and {@link ExternalLocationCase#getExternalNodeConnector()} MUST NOT be {@code null}
273 * @return {@link ListenableFuture}
275 public synchronized @Nonnull ListenableFuture<Void> addBridgeDomainToInterface(@Nonnull String bridgeDomainName,
276 @Nonnull AddressEndpointWithLocation addrEpWithLoc) {
277 ExternalLocationCase epLoc = resolveAndValidateLocation(addrEpWithLoc);
278 InstanceIdentifier<?> vppNodeIid = epLoc.getExternalNodeMountPoint();
279 String interfacePath = epLoc.getExternalNodeConnector();
281 Optional<InstanceIdentifier<Interface>> optInterfaceIid =
282 VppPathMapper.interfaceToInstanceIdentifier(interfacePath);
283 if (!optInterfaceIid.isPresent()) {
284 return Futures.immediateFailedFuture(
285 new Exception("Cannot resolve interface instance-identifier for interface path" + interfacePath));
287 InstanceIdentifier<Interface> interfaceIid = optInterfaceIid.get();
289 Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
290 if (!potentialVppDataProvider.isPresent()) {
291 return Futures.immediateFailedFuture(new Exception("Cannot get data broker for mount point " + vppNodeIid));
293 final DataBroker mountpoint = potentialVppDataProvider.get();
294 final ReadWriteTransaction rwTx = mountpoint.newReadWriteTransaction();
295 CheckedFuture<Optional<Interface>, ReadFailedException> futureIface =
296 rwTx.read(LogicalDatastoreType.CONFIGURATION, interfaceIid);
297 return Futures.transform(futureIface, new AsyncFunction<Optional<Interface>, Void>() {
300 public ListenableFuture<Void> apply(Optional<Interface> optIface) throws Exception {
301 if (!optIface.isPresent()) {
302 return Futures.immediateFailedFuture(new Exception("Iterface "
303 + interfaceIid.firstKeyOf(Interface.class) + " does not exist on node " + vppNodeIid));
306 String existingBridgeDomain = resolveBridgeDomain(optIface.get());
307 if (bridgeDomainName.equals(existingBridgeDomain)) {
308 LOG.debug("Bridge domain {} already exists on interface {}", bridgeDomainName, interfacePath);
309 String bridgeDomainPath = VppPathMapper.bridgeDomainToRestPath(bridgeDomainName);
310 if (!bridgeDomainPath.equals(epLoc.getExternalNode())) {
311 return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
312 .setExternalNode(bridgeDomainPath)
313 .setExternalNodeMountPoint(vppNodeIid)
314 .setExternalNodeConnector(interfacePath)
315 .build(), addrEpWithLoc.getKey());
317 return Futures.immediateFuture(null);
319 InstanceIdentifier<L2> l2Iid =
320 interfaceIid.builder().augmentation(VppInterfaceAugmentation.class).child(L2.class).build();
321 final ReadWriteTransaction rwTxRead = mountpoint.newReadWriteTransaction();
322 Optional<L2> optL2 = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, l2Iid, rwTxRead);
323 L2Builder l2Builder = (optL2.isPresent()) ? new L2Builder(optL2.get()) : new L2Builder();
324 L2 l2 = l2Builder.setInterconnection(new BridgeBasedBuilder().setBridgeDomain(bridgeDomainName).build()).build();
325 final ReadWriteTransaction rwTxPut = prepareTransactionAndPutData(mountpoint, l2, l2Iid);
326 LOG.debug("Adding bridge domain {} to interface {}", bridgeDomainName, interfacePath);
327 return Futures.transform(rwTxPut.submit(), new AsyncFunction<Void, Void>() {
330 public ListenableFuture<Void> apply(@Nonnull Void input) {
331 String bridgeDomainPath = VppPathMapper.bridgeDomainToRestPath(bridgeDomainName);
332 return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
333 .setExternalNode(bridgeDomainPath)
334 .setExternalNodeMountPoint(vppNodeIid)
335 .setExternalNodeConnector(interfacePath)
336 .build(), addrEpWithLoc.getKey());
344 * Removes bridge domain (if exist) from an interface (if exist).<br>
345 * {@link VppEndpointLocationProvider#VPP_ENDPOINT_LOCATION_PROVIDER} will update endpoint
348 * If the interface does not exist or other problems occur {@link ListenableFuture} will fail
349 * as {@link Futures#immediateFailedFuture(Throwable)} with {@link Exception}
350 * containing message in {@link Exception#getMessage()}
352 * @param addrEpWithLoc {@link AddressEndpointWithLocation} containing
353 * {@link ExternalLocationCase} where
354 * {@link ExternalLocationCase#getExternalNodeMountPoint()} MUST NOT be {@code null}
355 * and {@link ExternalLocationCase#getExternalNodeConnector()} MUST NOT be {@code null}
356 * @return {@link ListenableFuture}
358 public synchronized @Nonnull ListenableFuture<Void> deleteBridgeDomainFromInterface(
359 @Nonnull AddressEndpointWithLocation addrEpWithLoc) {
360 ExternalLocationCase epLoc = resolveAndValidateLocation(addrEpWithLoc);
361 InstanceIdentifier<?> vppNodeIid = epLoc.getExternalNodeMountPoint();
362 String interfacePath = epLoc.getExternalNodeConnector();
364 Optional<InstanceIdentifier<Interface>> optInterfaceIid =
365 VppPathMapper.interfaceToInstanceIdentifier(interfacePath);
366 if (!optInterfaceIid.isPresent()) {
367 return Futures.immediateFailedFuture(
368 new Exception("Cannot resolve interface instance-identifier for interface path" + interfacePath));
370 InstanceIdentifier<Interface> interfaceIid = optInterfaceIid.get();
372 Optional<DataBroker> potentialVppDataProvider = mountDataProvider.getDataBrokerForMountPoint(vppNodeIid);
373 if (!potentialVppDataProvider.isPresent()) {
374 return Futures.immediateFailedFuture(new Exception("Cannot get data broker for mount point " + vppNodeIid));
377 ReadWriteTransaction rwTx = potentialVppDataProvider.get().newReadWriteTransaction();
378 CheckedFuture<Optional<Interface>, ReadFailedException> futureIface =
379 rwTx.read(LogicalDatastoreType.CONFIGURATION, interfaceIid);
380 return Futures.transform(futureIface, new AsyncFunction<Optional<Interface>, Void>() {
383 public ListenableFuture<Void> apply(Optional<Interface> optIface) throws Exception {
384 if (!optIface.isPresent()) {
385 // interface does not exist so we consider job done
386 return Futures.immediateFuture(null);
388 String existingBridgeDomain = resolveBridgeDomain(optIface.get());
389 if (Strings.isNullOrEmpty(existingBridgeDomain)) {
390 LOG.debug("Bridge domain does not exist therefore it is considered as deleted for interface {}",
392 // bridge domain does not exist on interface so we consider job done
393 return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
394 .setExternalNode(null)
395 .setExternalNodeMountPoint(vppNodeIid)
396 .setExternalNodeConnector(interfacePath)
397 .build(), addrEpWithLoc.getKey());
399 InstanceIdentifier<L2> l2Iid =
400 interfaceIid.builder().augmentation(VppInterfaceAugmentation.class).child(L2.class).build();
401 rwTx.delete(LogicalDatastoreType.CONFIGURATION, l2Iid);
402 LOG.debug("Deleting bridge domain from interface {}", interfacePath);
403 return Futures.transform(rwTx.submit(), new AsyncFunction<Void, Void>() {
406 public ListenableFuture<Void> apply(@Nonnull Void input) {
407 return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
408 .setExternalNode(null)
409 .setExternalNodeMountPoint(vppNodeIid)
410 .setExternalNodeConnector(interfacePath)
411 .build(), addrEpWithLoc.getKey());
418 private static ExternalLocationCase resolveAndValidateLocation(AddressEndpointWithLocation addrEpWithLoc) {
419 LocationType locationType = addrEpWithLoc.getAbsoluteLocation().getLocationType();
420 if (!(locationType instanceof ExternalLocationCase)) {
421 throw new IllegalArgumentException("Endpoint does not have external location " + addrEpWithLoc);
423 ExternalLocationCase result = (ExternalLocationCase) locationType;
424 if (result.getExternalNodeMountPoint() == null || result.getExternalNodeConnector() == null) {
425 throw new IllegalArgumentException(
426 "Endpoint does not have external-node-mount-point or external-node-connector " + addrEpWithLoc);
431 private static @Nullable String resolveBridgeDomain(@Nonnull Interface iface) {
432 VppInterfaceAugmentation vppInterfaceAugmentation = iface.getAugmentation(VppInterfaceAugmentation.class);
433 L2 existingL2 = vppInterfaceAugmentation.getL2();
434 if (existingL2 != null) {
435 Interconnection interconnection = existingL2.getInterconnection();
436 if (interconnection instanceof BridgeBased) {
437 return ((BridgeBased) interconnection).getBridgeDomain();
443 private static boolean hasNodeAndInterface(VppEndpoint vppEp) {
444 if (vppEp.getVppNodePath() == null) {
445 LOG.debug("vpp-node is missing. {}", vppEp);
448 if (Strings.isNullOrEmpty(vppEp.getVppInterfaceName())) {
449 LOG.debug("vpp-interface-name is missing. {}", vppEp);
456 public void close() throws Exception {
457 vppEndpointLocationProvider.close();
460 // TODO workaround for netconf, remove when fixed
461 private synchronized <T extends DataObject> ReadWriteTransaction prepareTransactionAndPutData(final DataBroker mountpoint,
463 InstanceIdentifier<T> iid) {
464 final ReadWriteTransaction rwTx = mountpoint.newReadWriteTransaction();
466 rwTx.put(LogicalDatastoreType.CONFIGURATION, iid, data);
468 catch (IllegalStateException e) {
469 LOG.error("Assuming netconf transaction failed, restarting ...", e.getMessage());
470 return prepareTransactionAndPutData(mountpoint, data, iid);