Merge "Neutron port listener updated to support allowed address pair with security...
[netvirt.git] / vpnservice / neutronvpn / neutronvpn-impl / src / main / java / org / opendaylight / netvirt / neutronvpn / NeutronPortChangeListener.java
index 40f697c5c5a8f1aae33e2ff95c0708c4c04a9565..1ae7aed907f71537e2915f08c94db9e075a43d94 100644 (file)
@@ -66,19 +66,16 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private LockManagerService lockManager;
     private NotificationPublishService notificationPublishService;
     private NotificationService notificationService;
-    private NeutronFloatingToFixedIpMappingChangeListener floatingIpMapListener;
 
 
     public NeutronPortChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr,NeutronvpnNatManager nVpnNatMgr,
-                                     NotificationPublishService notiPublishService, NotificationService notiService,
-                                     NeutronFloatingToFixedIpMappingChangeListener neutronFloatingToFixedIpMappingChangeListener) {
+                                     NotificationPublishService notiPublishService, NotificationService notiService) {
         super(Port.class);
         broker = db;
         nvpnManager = nVpnMgr;
         nvpnNatManager = nVpnNatMgr;
         notificationPublishService = notiPublishService;
         notificationService = notiService;
-        floatingIpMapListener = neutronFloatingToFixedIpMappingChangeListener;
         registerListener(db);
     }
 
@@ -251,6 +248,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
 
     private void handleNeutronPortCreated(Port port) {
         if (!NeutronUtils.isPortVnicTypeNormal(port)) {
+            nvpnManager.updateSubnetmapNodeWithPorts(port.getFixedIps().get(0).getSubnetId(), null, port.getUuid());
             LOG.info("Port {} is not a NORMAL VNIC Type port; OF Port interfaces are not created",
                     port.getUuid().getValue());
             return;
@@ -276,8 +274,14 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     }
 
     private void handleNeutronPortDeleted(Port port) {
+        if (!NeutronUtils.isPortVnicTypeNormal(port)) {
+            nvpnManager.removePortsFromSubnetmapNode(port.getFixedIps().get(0).getSubnetId(), null, port.getUuid());
+            LOG.info("Port {} is not a NORMAL VNIC Type port; OF Port interfaces are not created",
+                    port.getUuid().getValue());
+            return;
+        }
         //dissociate fixedIP from floatingIP if associated
-        floatingIpMapListener.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
+        nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
         LOG.debug("Remove port from subnet");
         // remove port from local Subnets DS
         Uuid vpnId = removePortFromSubnets(port);
@@ -620,7 +624,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
         LOG.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
                 ipValue, infName);
         subnetId = ip.getSubnetId();
-        subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, null, port.getUuid());
+        subnetmap = nvpnManager.updateSubnetmapNodeWithPorts(subnetId, port.getUuid(), null);
         if (subnetmap != null) {
             vpnId = subnetmap.getVpnId();
         }
@@ -654,7 +658,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
         MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
         LOG.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS", ipValue);
         subnetId = ip.getSubnetId();
-        subnetmap = nvpnManager.removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
+        subnetmap = nvpnManager.removePortsFromSubnetmapNode(subnetId, port.getUuid(), null);
         if (subnetmap != null) {
             vpnId = subnetmap.getVpnId();
         }