+ /**
+ * If removed termination point was a tunnel port,
+ * removes attached tunnels (namely Vxlan-type) from OVSDB bridge,
+ * else removes location info from TP.
+ *
+ * @param nodeId {@link NodeId}
+ * @param ovsdbTp {@link OvsdbTerminationPointAugmentation}
+ * @param ovsdbTpIid termination point's IID {@link InstanceIdentifier}
+ */
+ private void processRemovedTp(NodeId nodeId, OvsdbTerminationPointAugmentation ovsdbTp,
+ InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid) {
+ if (isTunnelPort(ovsdbTp, requiredTunnelTypes)) {
+ removeTunnelsOfOverlayConfig(nodeId.getValue(), requiredTunnelTypes, dataBroker);
+ } else {
+ deleteLocationForTp(ovsdbTp);
+ }
+ }
+
+ /**
+ * Delete location on EP for given TP.
+ *
+ * @param ovsdbTp {@link OvsdbTerminationPointAugmentation}
+ */
+ private void deleteLocationForTp(OvsdbTerminationPointAugmentation ovsdbTp) {
+ String externalId = getNeutronPortUuid(ovsdbTp);
+ if (externalId != null) {
+ EndpointKey epKey = getEpKeyFromNeutronMapper(new UniqueId(externalId), dataBroker);
+ if (epKey == null) {
+ LOG.debug("TerminationPoint {} with external ID {} is not in Neutron Map.", ovsdbTp, externalId);
+ return;
+ }
+ ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();
+ Endpoint ep = lookupEndpoint(epKey, readOnlyTransaction);
+ readOnlyTransaction.close();
+ if (ep == null) {
+ LOG.warn("TerminationPoint {} with external ID {} is in Neutron Map,"
+ + " but corresponding Endpoint {} isn't in Endpoint Repository.", ovsdbTp, externalId, epKey);
+ return;
+ }
+ updateEndpointRemoveLocation(ep, dataBroker.newReadWriteTransaction());
+ } else {
+ LOG.debug("TerminationPoint {} has no external ID, not processing.", ovsdbTp);
+ }
+ }
+