@Test public void testRendererPolicyChanged_created_oneEpPerEpg() throws Exception { AbsoluteLocation clientLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_1_IFACE_NAME); AddressEndpointWithLocation clientEp = DtoFactory.createEndpoint(CLIENT_IP, CLIENT_MAC, DtoFactory.L2FD_CTX.getValue(), clientLocation); AbsoluteLocation webLocation = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, WEB_1_IFACE_NAME); AddressEndpointWithLocation webEp = DtoFactory.createEndpoint(WEB_IP, WEB_MAC, DtoFactory.L2FD_CTX.getValue(), webLocation); storeVppEndpoint(clientEp.getKey(), CLIENT_MAC, CLIENT_1_IFACE_NAME, createVppEndpointIid(clientEp.getKey())); storeVppEndpoint(webEp.getKey(), WEB_MAC, WEB_1_IFACE_NAME, createVppEndpointIid(webEp.getKey())); Configuration configuration = DtoFactory.createConfiguration(Collections.singletonList(clientEp), Collections.singletonList(webEp)); RendererPolicy rendererPolicy = new RendererPolicyBuilder().setVersion(1L).setConfiguration(configuration).build(); RendererPolicyConfEvent event = new RendererPolicyConfEvent(RENDERER_POLICY_IID, null, rendererPolicy); vppRendererPolicyManager.rendererPolicyChanged(event); Interface clientIface = readAndAssertInterface(CLIENT_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), clientIface); Interface webIface = readAndAssertInterface(WEB_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), webIface); ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); Optional<LocationProvider> optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION, IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER)) .get(); Assert.assertTrue(optLocationProvider.isPresent()); List<ProviderAddressEndpointLocation> epLocs = optLocationProvider.get().getProviderAddressEndpointLocation(); Assert.assertNotNull(epLocs); Assert.assertEquals(2, epLocs.size()); assertProviderAddressEndpointLocation(clientEp.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(webEp.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs); }
@Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); @Subscribe void rendererPolicyChanged(RendererPolicyConfEvent event); @Subscribe void vppNodeChanged(NodeOperEvent event); }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); @Subscribe void rendererPolicyChanged(RendererPolicyConfEvent event); @Subscribe void vppNodeChanged(NodeOperEvent event);  }