X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=dhcpservice%2Fdhcpservice-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fdhcpservice%2FDhcpL2GatewayConnectionListener.java;h=3d833768003240503125f9b79430bc3562d7459f;hb=457492a743696190dddf577c76aabac4d1af4139;hp=6ba17767dc2667928ceb7715d674d81428bf59a8;hpb=9909ff254706d57ff52ced55f83e2859257b7d6d;p=vpnservice.git diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpL2GatewayConnectionListener.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpL2GatewayConnectionListener.java index 6ba17767..3d833768 100644 --- a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpL2GatewayConnectionListener.java +++ b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpL2GatewayConnectionListener.java @@ -21,7 +21,7 @@ import org.opendaylight.vpnservice.dhcpservice.api.DHCPMConstants; import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; import org.opendaylight.vpnservice.neutronvpn.api.l2gw.L2GatewayDevice; import org.opendaylight.vpnservice.neutronvpn.api.l2gw.utils.L2GatewayCacheUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections; @@ -58,20 +58,13 @@ public class DhcpL2GatewayConnectionListener extends AsyncClusteredDataChangeLis .child(L2gateway.class, new L2gatewayKey(gatewayId)); Optional l2Gateway = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, inst); if (!l2Gateway.isPresent()) { + logger.trace("L2Gw not present id {}", gatewayId); return; } Uuid networkUuid = del.getNetworkId(); - boolean isLastConnection = true; - InstanceIdentifier l2gatewayConnectionIdentifier = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class); - Optional l2GwConnection = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, l2gatewayConnectionIdentifier); - List l2GatewayConnectionList = l2GwConnection.get().getL2gatewayConnection(); - for (L2gatewayConnection l2gatewayConnection : l2GatewayConnectionList) { - if (networkUuid.equals(l2gatewayConnection.getNetworkId())) { - isLastConnection = false; - break; - } - } + boolean isLastConnection = isLastGatewayConnection(networkUuid); if (!isLastConnection) { + logger.trace("Not the last L2GatewayConnection. Not removing flows."); return; } List l2Devices = l2Gateway.get().getDevices(); @@ -88,6 +81,20 @@ public class DhcpL2GatewayConnectionListener extends AsyncClusteredDataChangeLis } } + private boolean isLastGatewayConnection(Uuid networkUuid) { + boolean isLastConnection = true; + InstanceIdentifier l2gatewayConnectionIdentifier = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class); + Optional l2GwConnection = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, l2gatewayConnectionIdentifier); + List l2GatewayConnectionList = l2GwConnection.get().getL2gatewayConnection(); + for (L2gatewayConnection l2gatewayConnection : l2GatewayConnectionList) { + if (networkUuid.equals(l2gatewayConnection.getNetworkId())) { + isLastConnection = false; + break; + } + } + return isLastConnection; + } + @Override protected void update(InstanceIdentifier identifier, L2gatewayConnection original, L2gatewayConnection update) {