@Test public void testVppEndpointChanged_deleted() throws Exception { VppEndpoint vhostEp = vhostVppEpBuilder().build(); VppEndpointConfEvent createVppEpEvent = new VppEndpointConfEvent(BASIC_VPP_EP_IID, null, vhostEp); VppEndpointConfEvent deleteVppEpEvent = new VppEndpointConfEvent(BASIC_VPP_EP_IID, vhostEp, null); VbdNetconfTransaction.NODE_DATA_BROKER_MAP.put(VppIidFactory.getNetconfNodeIid(vhostEp.getVppNodeId()), new AbstractMap.SimpleEntry<DataBroker, ReentrantLock>(mountPointDataBroker, new ReentrantLock())); manager.vppEndpointChanged(createVppEpEvent); manager.vppEndpointChanged(deleteVppEpEvent); ReadOnlyTransaction rTxMount = mountPointDataBroker.newReadOnlyTransaction(); Optional<Interface> potentialIface = rTxMount.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Interfaces.class) .child(Interface.class, new InterfaceKey(vhostEp.getVppInterfaceName())) .build()).get(); Assert.assertFalse(potentialIface.isPresent()); ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); VppLocationUtils.createProviderAddressEndpointLocationKey(vhostEp); InstanceIdentifier<ProviderAddressEndpointLocation> providerAddressEndpointLocationIid = IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER, VppLocationUtils.createProviderAddressEndpointLocationKey(vhostEp)); Optional<ProviderAddressEndpointLocation> optProvEpLoc = rTx.read(LogicalDatastoreType.CONFIGURATION, providerAddressEndpointLocationIid).get(); Assert.assertFalse(optProvEpLoc.isPresent()); }
@Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") public synchronized void vppEndpointChanged(VppEndpointConfEvent event) { String message; final VppEndpoint oldVppEndpoint = event.getBefore().orNull(); final VppEndpoint newVppEndpoint = event.getAfter().orNull(); try { switch (event.getDtoModificationType()) { case CREATED: { Preconditions.checkNotNull(newVppEndpoint); vppEndpointCreated(newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s created", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(newVppEndpoint, true).get(); } break; case UPDATED: { Preconditions.checkNotNull(oldVppEndpoint); Preconditions.checkNotNull(newVppEndpoint); vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s updated", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(oldVppEndpoint, true).get(); } break; case DELETED: { Preconditions.checkNotNull(oldVppEndpoint); vppEndpointDeleted(oldVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s removed", oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(), oldVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(event.getBefore().get(), false).get(); } break; default: { message = "Unknown event modification type: " + event.getDtoModificationType(); LOG.error("Failed to process VPP endpoint {}. {}", (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(), event.getAfter(), new VppRendererProcessingException(message)); } } LOG.info(message); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(), event.getAfter(), e); } }
InterfaceManager implements AutoCloseable { @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") public synchronized void vppEndpointChanged(VppEndpointConfEvent event) { String message; final VppEndpoint oldVppEndpoint = event.getBefore().orNull(); final VppEndpoint newVppEndpoint = event.getAfter().orNull(); try { switch (event.getDtoModificationType()) { case CREATED: { Preconditions.checkNotNull(newVppEndpoint); vppEndpointCreated(newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s created", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(newVppEndpoint, true).get(); } break; case UPDATED: { Preconditions.checkNotNull(oldVppEndpoint); Preconditions.checkNotNull(newVppEndpoint); vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s updated", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(oldVppEndpoint, true).get(); } break; case DELETED: { Preconditions.checkNotNull(oldVppEndpoint); vppEndpointDeleted(oldVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s removed", oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(), oldVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(event.getBefore().get(), false).get(); } break; default: { message = "Unknown event modification type: " + event.getDtoModificationType(); LOG.error("Failed to process VPP endpoint {}. {}", (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(), event.getAfter(), new VppRendererProcessingException(message)); } } LOG.info(message); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(), event.getAfter(), e); } } }
InterfaceManager implements AutoCloseable { @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") public synchronized void vppEndpointChanged(VppEndpointConfEvent event) { String message; final VppEndpoint oldVppEndpoint = event.getBefore().orNull(); final VppEndpoint newVppEndpoint = event.getAfter().orNull(); try { switch (event.getDtoModificationType()) { case CREATED: { Preconditions.checkNotNull(newVppEndpoint); vppEndpointCreated(newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s created", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(newVppEndpoint, true).get(); } break; case UPDATED: { Preconditions.checkNotNull(oldVppEndpoint); Preconditions.checkNotNull(newVppEndpoint); vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s updated", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(oldVppEndpoint, true).get(); } break; case DELETED: { Preconditions.checkNotNull(oldVppEndpoint); vppEndpointDeleted(oldVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s removed", oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(), oldVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(event.getBefore().get(), false).get(); } break; default: { message = "Unknown event modification type: " + event.getDtoModificationType(); LOG.error("Failed to process VPP endpoint {}. {}", (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(), event.getAfter(), new VppRendererProcessingException(message)); } } LOG.info(message); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(), event.getAfter(), e); } } InterfaceManager(@Nonnull MountedDataBrokerProvider mountDataProvider, @Nonnull DataBroker dataProvider); }
InterfaceManager implements AutoCloseable { @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") public synchronized void vppEndpointChanged(VppEndpointConfEvent event) { String message; final VppEndpoint oldVppEndpoint = event.getBefore().orNull(); final VppEndpoint newVppEndpoint = event.getAfter().orNull(); try { switch (event.getDtoModificationType()) { case CREATED: { Preconditions.checkNotNull(newVppEndpoint); vppEndpointCreated(newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s created", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(newVppEndpoint, true).get(); } break; case UPDATED: { Preconditions.checkNotNull(oldVppEndpoint); Preconditions.checkNotNull(newVppEndpoint); vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s updated", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(oldVppEndpoint, true).get(); } break; case DELETED: { Preconditions.checkNotNull(oldVppEndpoint); vppEndpointDeleted(oldVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s removed", oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(), oldVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(event.getBefore().get(), false).get(); } break; default: { message = "Unknown event modification type: " + event.getDtoModificationType(); LOG.error("Failed to process VPP endpoint {}. {}", (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(), event.getAfter(), new VppRendererProcessingException(message)); } } LOG.info(message); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(), event.getAfter(), e); } } InterfaceManager(@Nonnull MountedDataBrokerProvider mountDataProvider, @Nonnull DataBroker dataProvider); @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") synchronized void vppEndpointChanged(VppEndpointConfEvent event); ListenableFuture<Void> createInterfaceOnVpp(final ConfigCommand createIfaceWithoutBdCommand,
                                                       final InstanceIdentifier<Node> vppIid); @Subscribe synchronized void vppNodeChanged(NodeOperEvent event); synchronized ListenableFuture<Void> addBridgeDomainToInterface(@Nonnull String bridgeDomainName,
        @Nonnull AddressEndpointWithLocation addrEpWithLoc, @Nonnull List<AccessListWrapper> aclWrappers,
        boolean enableBvi); boolean isExcludedFromPolicy(@Nonnull NodeId nodeId,@Nonnull String interfaceName); ListenableFuture<Void> configureInterface(InstanceIdentifier<Node> vppIid, InterfaceKey ifaceKey,
        @Nullable String bridgeDomainName, @Nullable Boolean enableBvi); ListenableFuture<Void> removeInterfaceFromBridgeDomain(InstanceIdentifier<Node> vppIid,
        InterfaceKey ifaceKey); synchronized @Nonnull ListenableFuture<Void> deleteBridgeDomainFromInterface(
            @Nonnull AddressEndpointWithLocation addrEpWithLoc); static ExternalLocationCase resolveAndValidateLocation(AddressEndpointWithLocation addrEpWithLoc); @Override void close(); }
InterfaceManager implements AutoCloseable { @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") public synchronized void vppEndpointChanged(VppEndpointConfEvent event) { String message; final VppEndpoint oldVppEndpoint = event.getBefore().orNull(); final VppEndpoint newVppEndpoint = event.getAfter().orNull(); try { switch (event.getDtoModificationType()) { case CREATED: { Preconditions.checkNotNull(newVppEndpoint); vppEndpointCreated(newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s created", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(newVppEndpoint, true).get(); } break; case UPDATED: { Preconditions.checkNotNull(oldVppEndpoint); Preconditions.checkNotNull(newVppEndpoint); vppEndpointUpdated(oldVppEndpoint, newVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s updated", newVppEndpoint.getAddress(), newVppEndpoint.getVppNodeId().getValue(), newVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(oldVppEndpoint, true).get(); } break; case DELETED: { Preconditions.checkNotNull(oldVppEndpoint); vppEndpointDeleted(oldVppEndpoint).get(); message = String.format("Vpp endpoint %s on node %s and interface %s removed", oldVppEndpoint.getAddress(), oldVppEndpoint.getVppNodeId().getValue(), oldVppEndpoint.getVppInterfaceName()); updatePolicyExcludedEndpoints(event.getBefore().get(), false).get(); } break; default: { message = "Unknown event modification type: " + event.getDtoModificationType(); LOG.error("Failed to process VPP endpoint {}. {}", (oldVppEndpoint != null) ? oldVppEndpoint.getKey() : newVppEndpoint.getKey(), event.getAfter(), new VppRendererProcessingException(message)); } } LOG.info(message); } catch (InterruptedException | ExecutionException e) { LOG.error("Failed to process changed vpp endpoint. before: {}, after: {}.Exception: {} ", event.getBefore(), event.getAfter(), e); } } InterfaceManager(@Nonnull MountedDataBrokerProvider mountDataProvider, @Nonnull DataBroker dataProvider); @Subscribe @SuppressWarnings("OptionalGetWithoutIsPresent") synchronized void vppEndpointChanged(VppEndpointConfEvent event); ListenableFuture<Void> createInterfaceOnVpp(final ConfigCommand createIfaceWithoutBdCommand,
                                                       final InstanceIdentifier<Node> vppIid); @Subscribe synchronized void vppNodeChanged(NodeOperEvent event); synchronized ListenableFuture<Void> addBridgeDomainToInterface(@Nonnull String bridgeDomainName,
        @Nonnull AddressEndpointWithLocation addrEpWithLoc, @Nonnull List<AccessListWrapper> aclWrappers,
        boolean enableBvi); boolean isExcludedFromPolicy(@Nonnull NodeId nodeId,@Nonnull String interfaceName); ListenableFuture<Void> configureInterface(InstanceIdentifier<Node> vppIid, InterfaceKey ifaceKey,
        @Nullable String bridgeDomainName, @Nullable Boolean enableBvi); ListenableFuture<Void> removeInterfaceFromBridgeDomain(InstanceIdentifier<Node> vppIid,
        InterfaceKey ifaceKey); synchronized @Nonnull ListenableFuture<Void> deleteBridgeDomainFromInterface(
            @Nonnull AddressEndpointWithLocation addrEpWithLoc); static ExternalLocationCase resolveAndValidateLocation(AddressEndpointWithLocation addrEpWithLoc); @Override void close();  }