+ if (!optInterface.isPresent()) {
+ return Futures.immediateFailedFuture(new Exception("Interface "
+ + interfaceIid.firstKeyOf(Interface.class) + " does not exist on node " + vppNodeIid));
+ }
+ String existingBridgeDomain = resolveBridgeDomain(optInterface.get());
+ if (bridgeDomainName.equals(existingBridgeDomain)) {
+ LOG.debug("Bridge domain {} already exists on interface {}", bridgeDomainName, interfacePath);
+ String bridgeDomainPath = VppPathMapper.bridgeDomainToRestPath(bridgeDomainName);
+ if (!bridgeDomainPath.equals(epLoc.getExternalNode())) {
+ return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
+ .setExternalNode(bridgeDomainPath)
+ .setExternalNodeMountPoint(vppNodeIid)
+ .setExternalNodeConnector(interfacePath)
+ .build(), addrEpWithLoc.getKey());
+ }
+ return Futures.immediateFuture(null);
+ }
+ InstanceIdentifier<L2> l2Iid =
+ interfaceIid.builder().augmentation(VppInterfaceAugmentation.class).child(L2.class).build();
+ Optional<L2> optL2 = GbpNetconfTransaction.read(mountpoint, LogicalDatastoreType.CONFIGURATION,
+ l2Iid, GbpNetconfTransaction.RETRY_COUNT);
+ L2Builder l2Builder = (optL2.isPresent()) ? new L2Builder(optL2.get()) : new L2Builder();
+ L2 l2 = l2Builder.setInterconnection(new BridgeBasedBuilder()
+ .setBridgeDomain(bridgeDomainName)
+ .setBridgedVirtualInterface(enableBvi)
+ .build()).build();
+ LOG.debug("Adding bridge domain {} to interface {}", bridgeDomainName, interfacePath);
+ final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(mountpoint, l2Iid, l2,
+ GbpNetconfTransaction.RETRY_COUNT);
+ if (transactionState) {
+ LOG.debug("Adding bridge domain {} to interface {} successful", bridgeDomainName, interfacePath);
+ Set<String> excludedIfaces = excludedFromPolicy.get(vppNodeIid.firstKeyOf(Node.class).getNodeId());
+ if(excludedIfaces == null || !excludedIfaces.contains(interfaceIid.firstKeyOf(Interface.class).getName())) {
+ // can apply ACLs on interfaces in bridge domains
+ aclWrappers.forEach(aclWrapper -> {
+ LOG.debug("Writing access list for interface {} on a node {}.", interfaceIid,
+ vppNodeIid);
+ aclWrapper.writeAcl(mountpoint, interfaceIid.firstKeyOf(Interface.class));
+ aclWrapper.writeAclRefOnIface(mountpoint, interfaceIid);
+ });
+ }
+ String bridgeDomainPath = VppPathMapper.bridgeDomainToRestPath(bridgeDomainName);
+ return vppEndpointLocationProvider.replaceLocationForEndpoint(new ExternalLocationCaseBuilder()
+ .setExternalNode(bridgeDomainPath)
+ .setExternalNodeMountPoint(vppNodeIid)
+ .setExternalNodeConnector(interfacePath)
+ .build(), addrEpWithLoc.getKey());
+ } else {
+ final String message = "Adding bridge domain " + bridgeDomainName + " to interface " + interfacePath + " failed";
+ LOG.warn(message);
+ return Futures.immediateFailedFuture(new VppRendererProcessingException(message));
+ }
+ }