@Test public void testRemoveBridgeDomainFromVppNode() { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getTopologyIid(BASE_TOPOLOGY.getKey()), BASE_TOPOLOGY, true); boolean result = DataStoreHelper.submitToDs(writeTransaction); Assert.assertTrue(result); Optional<Node> topologyOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getNodeIid(new TopologyKey(BASE_TOPOLOGY_ID), new NodeKey(VPP_NODE_ID)), dataBroker.newReadOnlyTransaction()); Assert.assertTrue(topologyOptional.isPresent()); bridgeDomainManager.removeBridgeDomainFromVppNode(BRIDGE_DOMAIN_ID, VPP_NODE_ID); topologyOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getNodeIid(new TopologyKey(BASE_TOPOLOGY_ID), new NodeKey(VPP_NODE_ID)), dataBroker.newReadOnlyTransaction()); Assert.assertFalse(topologyOptional.isPresent()); }
@Override public ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName, @Nonnull final NodeId vppNode) { LOG.info("Removing bridge domain {} from VPP node {}", bridgeDomainName, vppNode); InstanceIdentifier<Topology> topologyIid = VppIidFactory.getTopologyIid(new TopologyKey(new TopologyId(bridgeDomainName))); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Topology> topologyOpt = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, topologyIid, rTx); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(new TopologyKey(new TopologyId(bridgeDomainName)), new NodeKey(vppNode)); wTx.delete(LogicalDatastoreType.CONFIGURATION, nodeIid); if (topologyOpt.isPresent()) { Topology topology = topologyOpt.get(); if(topology.getNode() == null || topology.getNode().size() == 1) { wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIid); } } SettableFuture<Void> future = SettableFuture.create(); Futures.addCallback(wTx.submit(), new FutureCallback<Void>() { @Override public void onSuccess(Void result) { DataTreeIdentifier<BridgeMember> bridgeMemberIid = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodeIid.augmentation(NodeVbridgeAugment.class).child(BridgeMember.class)); LOG.debug("Request delete node in topology for VBD was stored to CONF DS. {}", nodeIid); new ListenableFutureSetter<>(dataProvider, future, bridgeMemberIid, ModificationType.DELETE); } @Override public void onFailure(@Nonnull Throwable t) { LOG.warn("Request delete node in topology for VBD was not stored to CONF DS. {}", nodeIid, t); future.setException(new Exception("Cannot send request to VBD.")); } }, MoreExecutors.directExecutor()); return future; }
BridgeDomainManagerImpl implements BridgeDomainManager { @Override public ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName, @Nonnull final NodeId vppNode) { LOG.info("Removing bridge domain {} from VPP node {}", bridgeDomainName, vppNode); InstanceIdentifier<Topology> topologyIid = VppIidFactory.getTopologyIid(new TopologyKey(new TopologyId(bridgeDomainName))); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Topology> topologyOpt = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, topologyIid, rTx); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(new TopologyKey(new TopologyId(bridgeDomainName)), new NodeKey(vppNode)); wTx.delete(LogicalDatastoreType.CONFIGURATION, nodeIid); if (topologyOpt.isPresent()) { Topology topology = topologyOpt.get(); if(topology.getNode() == null || topology.getNode().size() == 1) { wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIid); } } SettableFuture<Void> future = SettableFuture.create(); Futures.addCallback(wTx.submit(), new FutureCallback<Void>() { @Override public void onSuccess(Void result) { DataTreeIdentifier<BridgeMember> bridgeMemberIid = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodeIid.augmentation(NodeVbridgeAugment.class).child(BridgeMember.class)); LOG.debug("Request delete node in topology for VBD was stored to CONF DS. {}", nodeIid); new ListenableFutureSetter<>(dataProvider, future, bridgeMemberIid, ModificationType.DELETE); } @Override public void onFailure(@Nonnull Throwable t) { LOG.warn("Request delete node in topology for VBD was not stored to CONF DS. {}", nodeIid, t); future.setException(new Exception("Cannot send request to VBD.")); } }, MoreExecutors.directExecutor()); return future; } }
BridgeDomainManagerImpl implements BridgeDomainManager { @Override public ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName, @Nonnull final NodeId vppNode) { LOG.info("Removing bridge domain {} from VPP node {}", bridgeDomainName, vppNode); InstanceIdentifier<Topology> topologyIid = VppIidFactory.getTopologyIid(new TopologyKey(new TopologyId(bridgeDomainName))); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Topology> topologyOpt = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, topologyIid, rTx); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(new TopologyKey(new TopologyId(bridgeDomainName)), new NodeKey(vppNode)); wTx.delete(LogicalDatastoreType.CONFIGURATION, nodeIid); if (topologyOpt.isPresent()) { Topology topology = topologyOpt.get(); if(topology.getNode() == null || topology.getNode().size() == 1) { wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIid); } } SettableFuture<Void> future = SettableFuture.create(); Futures.addCallback(wTx.submit(), new FutureCallback<Void>() { @Override public void onSuccess(Void result) { DataTreeIdentifier<BridgeMember> bridgeMemberIid = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodeIid.augmentation(NodeVbridgeAugment.class).child(BridgeMember.class)); LOG.debug("Request delete node in topology for VBD was stored to CONF DS. {}", nodeIid); new ListenableFutureSetter<>(dataProvider, future, bridgeMemberIid, ModificationType.DELETE); } @Override public void onFailure(@Nonnull Throwable t) { LOG.warn("Request delete node in topology for VBD was not stored to CONF DS. {}", nodeIid, t); future.setException(new Exception("Cannot send request to VBD.")); } }, MoreExecutors.directExecutor()); return future; } BridgeDomainManagerImpl(DataBroker dataProvider); }
BridgeDomainManagerImpl implements BridgeDomainManager { @Override public ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName, @Nonnull final NodeId vppNode) { LOG.info("Removing bridge domain {} from VPP node {}", bridgeDomainName, vppNode); InstanceIdentifier<Topology> topologyIid = VppIidFactory.getTopologyIid(new TopologyKey(new TopologyId(bridgeDomainName))); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Topology> topologyOpt = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, topologyIid, rTx); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(new TopologyKey(new TopologyId(bridgeDomainName)), new NodeKey(vppNode)); wTx.delete(LogicalDatastoreType.CONFIGURATION, nodeIid); if (topologyOpt.isPresent()) { Topology topology = topologyOpt.get(); if(topology.getNode() == null || topology.getNode().size() == 1) { wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIid); } } SettableFuture<Void> future = SettableFuture.create(); Futures.addCallback(wTx.submit(), new FutureCallback<Void>() { @Override public void onSuccess(Void result) { DataTreeIdentifier<BridgeMember> bridgeMemberIid = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodeIid.augmentation(NodeVbridgeAugment.class).child(BridgeMember.class)); LOG.debug("Request delete node in topology for VBD was stored to CONF DS. {}", nodeIid); new ListenableFutureSetter<>(dataProvider, future, bridgeMemberIid, ModificationType.DELETE); } @Override public void onFailure(@Nonnull Throwable t) { LOG.warn("Request delete node in topology for VBD was not stored to CONF DS. {}", nodeIid, t); future.setException(new Exception("Cannot send request to VBD.")); } }, MoreExecutors.directExecutor()); return future; } BridgeDomainManagerImpl(DataBroker dataProvider); @Override ListenableFuture<Void> createVxlanBridgeDomainOnVppNode(@Nonnull final String bridgeDomainName,
                                                                   @Nonnull final VxlanVni vni,
                                                                   @Nonnull final NodeId vppNodeId); @Override ListenableFuture<Void> createVlanBridgeDomainOnVppNode(@Nonnull final String bridgeDomainName,
                                                                  @Nonnull final VlanId vlanId,
                                                                  @Nonnull final NodeId vppNodeId); @Override ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName,
                                                                @Nonnull final NodeId vppNode); }
BridgeDomainManagerImpl implements BridgeDomainManager { @Override public ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName, @Nonnull final NodeId vppNode) { LOG.info("Removing bridge domain {} from VPP node {}", bridgeDomainName, vppNode); InstanceIdentifier<Topology> topologyIid = VppIidFactory.getTopologyIid(new TopologyKey(new TopologyId(bridgeDomainName))); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<Topology> topologyOpt = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, topologyIid, rTx); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(new TopologyKey(new TopologyId(bridgeDomainName)), new NodeKey(vppNode)); wTx.delete(LogicalDatastoreType.CONFIGURATION, nodeIid); if (topologyOpt.isPresent()) { Topology topology = topologyOpt.get(); if(topology.getNode() == null || topology.getNode().size() == 1) { wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIid); } } SettableFuture<Void> future = SettableFuture.create(); Futures.addCallback(wTx.submit(), new FutureCallback<Void>() { @Override public void onSuccess(Void result) { DataTreeIdentifier<BridgeMember> bridgeMemberIid = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodeIid.augmentation(NodeVbridgeAugment.class).child(BridgeMember.class)); LOG.debug("Request delete node in topology for VBD was stored to CONF DS. {}", nodeIid); new ListenableFutureSetter<>(dataProvider, future, bridgeMemberIid, ModificationType.DELETE); } @Override public void onFailure(@Nonnull Throwable t) { LOG.warn("Request delete node in topology for VBD was not stored to CONF DS. {}", nodeIid, t); future.setException(new Exception("Cannot send request to VBD.")); } }, MoreExecutors.directExecutor()); return future; } BridgeDomainManagerImpl(DataBroker dataProvider); @Override ListenableFuture<Void> createVxlanBridgeDomainOnVppNode(@Nonnull final String bridgeDomainName,
                                                                   @Nonnull final VxlanVni vni,
                                                                   @Nonnull final NodeId vppNodeId); @Override ListenableFuture<Void> createVlanBridgeDomainOnVppNode(@Nonnull final String bridgeDomainName,
                                                                  @Nonnull final VlanId vlanId,
                                                                  @Nonnull final NodeId vppNodeId); @Override ListenableFuture<Void> removeBridgeDomainFromVppNode(@Nonnull final String bridgeDomainName,
                                                                @Nonnull final NodeId vppNode);  }