Merge SubnetInfo in AclInterface 27/79927/4
authorShashidhar Raja <shashidharr@altencalsoftlabs.com>
Fri, 25 Jan 2019 14:18:46 +0000 (19:48 +0530)
committerSam Hague <shague@redhat.com>
Sat, 26 Jan 2019 22:45:50 +0000 (22:45 +0000)
Change-Id: I8d2960605b84c3d53eed3d327730931a2995301a
Signed-off-by: Shashidhar Raja <shashidharr@altencalsoftlabs.com>
13 files changed:
aclservice/api/src/main/java/org/opendaylight/netvirt/aclservice/api/utils/AclInterface.java
aclservice/api/src/main/yang/aclservice.yang
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AbstractAclServiceImpl.java
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/EgressAclServiceImpl.java
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/IngressAclServiceImpl.java
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/listeners/AclInterfaceListener.java
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/listeners/AclInterfaceStateListener.java
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/utils/AclServiceUtils.java
aclservice/impl/src/test/java/org/opendaylight/netvirt/aclservice/tests/AclServiceTestBase.java
aclservice/impl/src/test/java/org/opendaylight/netvirt/aclservice/tests/IdentifiedInterfaceWithAclBuilder.java
aclservice/impl/src/test/java/org/opendaylight/netvirt/aclservice/tests/IdentifiedPortSubnetBuilder.java [deleted file]
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java

index 9a451304d136150d0070b91b42ccca4d6851ec03..1699bf00e512badaf2278e42dcfbafb868dd313d 100644 (file)
@@ -15,7 +15,7 @@ import java.util.SortedSet;
 import javax.annotation.Nullable;
 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.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 
 /**
  * The Class AclInterface.
index 0ab2b6262000a27e952ee6cc48f57b010edce903..1a005b8d68face42bf238d79066e038dd534aef3 100644 (file)
@@ -124,43 +124,32 @@ module aclservice {
                 type ip-prefix-or-address;
             }
         }
-    }
-
-    container port-subnets {
-        config false;
-        list port-subnet {
-            key port-id;
-            leaf port-id {
-                type string;
-                description "Port ID";
+        list subnet-info {
+            key subnet-id;
+            leaf subnet-id {
+                type yang:uuid;
+                description "Subnet ID";
             }
-            list subnet-info {
-                key subnet-id;
-                leaf subnet-id {
-                    type yang:uuid;
-                    description "Subnet ID";
+            leaf ip-version {
+                description "IP version";
+                type identityref {
+                    base "ip-version-base";
                 }
-                leaf ip-version {
-                    description "IP version";
-                    type identityref {
-                        base "ip-version-base";
-                    }
-                }
-                leaf ip-prefix {
-                    type ip-prefix-or-address;
-                    description "Subnet IP prefix.";
-                }
-                leaf ipv6-ra-mode {
-                    description "IPv6 RA mode";
-                    type identityref {
-                        base "dhcpv6-base";
-                    }
-                }
-                leaf gateway-ip {
-                    type inet:ip-address;
-                    description "default gateway used by devices in this subnet";
+            }
+            leaf ip-prefix {
+                type ip-prefix-or-address;
+                description "Subnet IP prefix.";
+            }
+            leaf ipv6-ra-mode {
+                description "IPv6 RA mode";
+                type identityref {
+                    base "dhcpv6-base";
                 }
             }
+            leaf gateway-ip {
+                type inet:ip-address;
+                description "default gateway used by devices in this subnet";
+            }
         }
     }
 
index 771922214798cbd25a0b0c177cf4d4106cd4754d..a9136cf02d09c98435321be1f94d0e142e743d4a 100644 (file)
@@ -65,7 +65,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index a80e61c2f5a4684e08d7f19101ed1ef93b30bfed..4487c8b278e17540722758d4586e48cd21640bb2 100644 (file)
@@ -47,7 +47,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
index 5727a6d19f7b8e6d8a32c86162515527ae2ad15d..9934ecab5c365e2934c107b95419dde36bde96e0 100644 (file)
@@ -47,7 +47,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
index 3c386980d8fb8d9cbd4bf2c2a15f1e5599ef5ec5..e076fdbbd980bcf0c354394ec4145418e613c063 100644 (file)
@@ -93,7 +93,6 @@ public class AclInterfaceListener extends AsyncDataTreeChangeListenerBase<Interf
                 if (aclInterface.getDpId() != null) {
                     aclServiceManager.notify(aclInterface, null, Action.REMOVE);
                 }
-                aclServiceUtils.deleteSubnetInfo(interfaceId);
             }
         }
     }
@@ -209,7 +208,7 @@ public class AclInterfaceListener extends AsyncDataTreeChangeListenerBase<Interf
             if (aclInPort != null) {
                 sgs = aclInPort.getSecurityGroups();
                 builder.portSecurityEnabled(aclInPort.isPortSecurityEnabled()).securityGroups(sgs)
-                        .allowedAddressPairs(aclInPort.getAllowedAddressPairs());
+                        .allowedAddressPairs(aclInPort.getAllowedAddressPairs()).subnetInfo(aclInPort.getSubnetInfo());
             }
 
             if ((prevAclInterface == null || prevAclInterface.getLPortTag() == null) && interfaceState != null) {
@@ -217,7 +216,6 @@ public class AclInterfaceListener extends AsyncDataTreeChangeListenerBase<Interf
                         .lPortTag(interfaceState.getIfIndex()).isMarkedForDelete(false);
             }
 
-            builder.subnetInfo(aclServiceUtils.getSubnetInfo(interfaceId));
             if (prevAclInterface == null || prevAclInterface.getElanId() == null) {
                 builder.elanId(AclServiceUtils.getElanIdFromInterface(interfaceId, dataBroker));
             }
index 66eb57481cb0de2b4c737fdea758a39bee068d9c..929222ef9db5890ec10adde38dab9a58bb705f37 100644 (file)
@@ -35,7 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -140,28 +139,9 @@ public class AclInterfaceStateListener extends AsyncDataTreeChangeListenerBase<I
             return;
         }
 
-        AclInterface aclInterface = aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
-            builder.dpId(AclServiceUtils.getDpIdFromIterfaceState(added)).lPortTag(added.getIfIndex())
-                .isMarkedForDelete(false);
-
-            if (AclServiceUtils.isOfInterest(prevAclInterface)) {
-                if (prevAclInterface.getSubnetInfo() == null) {
-                    // For upgrades
-                    List<SubnetInfo> subnetInfo = aclServiceUtils.getSubnetInfo(added.getName());
-                    builder.subnetInfo(subnetInfo);
-                }
-                SortedSet<Integer> ingressRemoteAclTags =
-                        aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionIngress.class);
-                SortedSet<Integer> egressRemoteAclTags =
-                        aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionEgress.class);
-                builder.ingressRemoteAclTags(ingressRemoteAclTags).egressRemoteAclTags(egressRemoteAclTags);
-            }
-        });
-
-        List<Uuid> aclList = aclInterface.getSecurityGroups();
-        if (aclList == null) {
+        if (aclInterfaceCache.get(added.getName()) == null) {
             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
-                    .Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(added.getName());
+                        .Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(added.getName());
             if (iface == null) {
                 LOG.error("No interface with name {} available in interfaceConfig, servicing interfaceState ADD"
                         + "for ACL failed", added.getName());
@@ -173,9 +153,26 @@ public class AclInterfaceStateListener extends AsyncDataTreeChangeListenerBase<I
                         added.getName());
                 return;
             }
+            aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
+                builder.portSecurityEnabled(aclInPort.isPortSecurityEnabled())
+                    .securityGroups(aclInPort.getSecurityGroups())
+                    .allowedAddressPairs(aclInPort.getAllowedAddressPairs()).subnetInfo(aclInPort.getSubnetInfo());
+            });
         }
+        AclInterface aclInterface = aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
+            builder.dpId(AclServiceUtils.getDpIdFromIterfaceState(added)).lPortTag(added.getIfIndex())
+                .isMarkedForDelete(false);
+            if (AclServiceUtils.isOfInterest(prevAclInterface)) {
+                SortedSet<Integer> ingressRemoteAclTags =
+                        aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionIngress.class);
+                SortedSet<Integer> egressRemoteAclTags =
+                        aclServiceUtils.getRemoteAclTags(prevAclInterface.getSecurityGroups(), DirectionEgress.class);
+                builder.ingressRemoteAclTags(ingressRemoteAclTags).egressRemoteAclTags(egressRemoteAclTags);
+            }
+        });
 
         if (AclServiceUtils.isOfInterest(aclInterface)) {
+            List<Uuid> aclList = aclInterface.getSecurityGroups();
             if (aclList != null) {
                 aclDataUtil.addAclInterfaceMap(aclList, aclInterface);
             }
index b5144dea1f107e20c575b5666525ff0819de66f4..49cc0cfb7a4532eae4716b01405bf323cea57c44 100644 (file)
@@ -68,7 +68,6 @@ import org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort;
 import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister;
 import org.opendaylight.genius.mdsalutil.packet.IPProtocols;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
 import org.opendaylight.netvirt.aclservice.api.AclServiceManager.MatchCriteria;
 import org.opendaylight.netvirt.aclservice.api.utils.AclInterface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists;
@@ -120,7 +119,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionV6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.PortSubnets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.AclPortsByIp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.AclPortsByIpKey;
@@ -130,9 +128,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.acl.ports.by.ip.acl.ip.prefixes.PortIdsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.acl.ports.lookup.acl.ports.by.ip.acl.ip.prefixes.PortIdsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnet;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
@@ -737,25 +733,6 @@ public final class AclServiceUtils {
                 .child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
     }
 
-    @Nullable
-    public List<SubnetInfo> getSubnetInfo(String portId) {
-        InstanceIdentifier<PortSubnet> id = InstanceIdentifier.builder(PortSubnets.class)
-                .child(PortSubnet.class, new PortSubnetKey(portId)).build();
-
-        Optional<PortSubnet> portSubnet = read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
-        if (portSubnet.isPresent()) {
-            return portSubnet.get().getSubnetInfo();
-        }
-        return null;
-    }
-
-    public void deleteSubnetInfo(String portId) {
-        InstanceIdentifier<PortSubnet> id = InstanceIdentifier.builder(PortSubnets.class)
-                .child(PortSubnet.class, new PortSubnetKey(portId)).build();
-        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
-                OPERATIONAL, tx -> tx.delete(id)), LOG, "Failed to delete subnet info for port: " + portId);
-    }
-
     public void deleteAcesFromConfigDS(String aclName, List<Ace> deletedAceRules) {
         List<List<Ace>> acesParts = Lists.partition(deletedAceRules, AclConstants.ACES_PER_TRANSACTION);
         for (List<Ace> acePart : acesParts) {
index 72f967c3997e797a241d30e5a7997f7dfabb73fa..f6fea804d84b37f77e939c8a81b16126b988239d 100644 (file)
@@ -57,9 +57,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionV4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfoKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
@@ -138,10 +138,9 @@ public abstract class AclServiceTestBase {
     public void newInterface() throws Exception {
         LOG.info("newInterface - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
         testInterfaceManager.addInterfaceInfo(newInterfaceInfo("port1"));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName("port1").addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
 
         // When
         putNewStateInterface(dataBroker, "port1", PORT_MAC_1);
@@ -159,12 +158,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithEtherTypeAcl() throws Exception {
         LOG.info("newInterfaceWithEtherTypeAcl - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
 
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
                 AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_UNSPECIFIED,
@@ -196,12 +193,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithMultipleAcl() throws Exception {
         LOG.info("newInterfaceWithEtherTypeAcl - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
 
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
                 AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_UNSPECIFIED,
@@ -244,8 +239,10 @@ public abstract class AclServiceTestBase {
         List<String> sgList = new ArrayList<>();
         sgList.add(SG_UUID_1);
         sgList.add(SG_UUID_2);
-        newAllowedAddressPair(PORT_1, sgList, Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, sgList, Collections.singletonList(AAP_PORT_2));
+        newAllowedAddressPair(PORT_1, sgList, Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, sgList, Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
 
         asyncEventsWaiter.awaitEventsConsumption();
         newInterfaceWithMultipleAclCheck();
@@ -257,12 +254,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithTcpDstAcl() throws Exception {
         LOG.info("newInterfaceWithTcpDstAcl - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
 
         // Given
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
@@ -296,12 +291,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithUdpDstAcl() throws Exception {
         LOG.info("newInterfaceWithUdpDstAcl - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
 
         // Given
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
@@ -336,12 +329,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithIcmpAcl() throws Exception {
         LOG.info("newInterfaceWithIcmpAcl - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
         // Given
         prepareInterfaceWithIcmpAcl();
 
@@ -362,9 +353,8 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithDstPortRange() throws Exception {
         LOG.info("newInterfaceWithDstPortRange - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
         // Given
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
                 AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 333, 777, AclConstants.SOURCE_REMOTE_IP_PREFIX_UNSPECIFIED,
@@ -394,9 +384,8 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithDstAllPorts() throws Exception {
         LOG.info("newInterfaceWithDstAllPorts - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
         // Given
         Matches matches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
                 AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, 1, 65535, AclConstants.SOURCE_REMOTE_IP_PREFIX_UNSPECIFIED,
@@ -426,9 +415,8 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithTwoAclsHavingSameRules() throws Exception {
         LOG.info("newInterfaceWithTwoAclsHavingSameRules - start");
 
-        newAllowedAddressPair(PORT_3, Arrays.asList(SG_UUID_1, SG_UUID_2), Collections.singletonList(AAP_PORT_3));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_3).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_3, Arrays.asList(SG_UUID_1, SG_UUID_2), Collections.singletonList(AAP_PORT_3),
+                Collections.singletonList(SUBNET_INFO_1));
         // Given
         Matches icmpEgressMatches = newMatch(AclConstants.SOURCE_LOWER_PORT_UNSPECIFIED,
                 AclConstants.SOURCE_UPPER_PORT_UNSPECIFIED, AclConstants.DEST_LOWER_PORT_2,
@@ -465,12 +453,10 @@ public abstract class AclServiceTestBase {
 
     @Test
     public void newInterfaceWithIcmpAclHavingOverlappingMac() throws Exception {
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2),
+                Collections.singletonList(SUBNET_INFO_1));
         // Given
         prepareInterfaceWithIcmpAcl();
 
@@ -487,16 +473,13 @@ public abstract class AclServiceTestBase {
     @Test
     public void newInterfaceWithAapIpv4All() throws Exception {
         LOG.info("newInterfaceWithAapIpv4All test - start");
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
         List<AllowedAddressPairs> aapList = new ArrayList<>();
         aapList.add(AAP_PORT_2);
         aapList.add(buildAap("0.0.0.0/0", PORT_MAC_2));
-        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), aapList);
-
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+        newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), aapList,
+                Collections.singletonList(SUBNET_INFO_1));
 
         prepareInterfaceWithIcmpAcl();
         // When
@@ -516,13 +499,10 @@ public abstract class AclServiceTestBase {
     public void newInterfaceWithAap() throws Exception {
         LOG.info("newInterfaceWithAap test - start");
 
-        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
+        newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1),
+                Collections.singletonList(SUBNET_INFO_1));
         newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1),
-                Arrays.asList(AAP_PORT_2, AAP_PORT_100, AAP_PORT_101));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_1).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
-        dataBrokerUtil.put(new IdentifiedPortSubnetBuilder().interfaceName(PORT_2).addAllSubnetInfo(
-                Collections.singletonList(SUBNET_INFO_1)));
+                Arrays.asList(AAP_PORT_2, AAP_PORT_100, AAP_PORT_101), Collections.singletonList(SUBNET_INFO_1));
 
         prepareInterfaceWithIcmpAcl();
         // When
@@ -561,14 +541,16 @@ public abstract class AclServiceTestBase {
                 .newMatches(matches).newDirection(DirectionIngress.class).build());
     }
 
-    protected void newAllowedAddressPair(String portName, List<String> sgUuidList, List<AllowedAddressPairs> aapList)
+    protected void newAllowedAddressPair(String portName, List<String> sgUuidList, List<AllowedAddressPairs> aapList,
+            List<SubnetInfo> subnetInfo)
             throws TransactionCommitFailedException {
         List<Uuid> sgList = sgUuidList.stream().map(Uuid::new).collect(Collectors.toList());
         Pair<DataTreeIdentifier<Interface>, Interface> port = new IdentifiedInterfaceWithAclBuilder()
                 .interfaceName(portName)
                 .portSecurity(true)
                 .addAllNewSecurityGroups(sgList)
-                .addAllIfAllowedAddressPairs(aapList).build();
+                .addAllIfAllowedAddressPairs(aapList)
+                .addAllIfSubnetInfo(subnetInfo).build();
         dataBrokerUtil.put(port);
         testInterfaceManager.addInterface(port.getValue());
     }
index 297b668fc23441f5e53dde46d9476650313eff25..16519ef16c3433f33dcb45dc1a4976c5996ade23 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 @NotThreadSafe
@@ -32,6 +33,7 @@ public class IdentifiedInterfaceWithAclBuilder implements DataTreeIdentifierData
     private Boolean portSecurity;
     private final List<Uuid> newSecurityGroups = new ArrayList<>();
     private final List<AllowedAddressPairs> ifAllowedAddressPairs = new ArrayList<>();
+    private final List<SubnetInfo> ifSubnetInfo = new ArrayList<>();
 
     @Override
     public LogicalDatastoreType type() {
@@ -51,6 +53,7 @@ public class IdentifiedInterfaceWithAclBuilder implements DataTreeIdentifierData
                 .setPortSecurityEnabled(portSecurity)
                 .setSecurityGroups(newSecurityGroups)
                 .setAllowedAddressPairs(ifAllowedAddressPairs)
+                .setSubnetInfo(ifSubnetInfo)
                 .build())
             .setName(interfaceName)
             .setType(L2vlan.class)
@@ -80,4 +83,8 @@ public class IdentifiedInterfaceWithAclBuilder implements DataTreeIdentifierData
         return this;
     }
 
+    public IdentifiedInterfaceWithAclBuilder addAllIfSubnetInfo(List<SubnetInfo> addToIfSubnetInfo) {
+        this.ifSubnetInfo.addAll(addToIfSubnetInfo);
+        return this;
+    }
 }
diff --git a/aclservice/impl/src/test/java/org/opendaylight/netvirt/aclservice/tests/IdentifiedPortSubnetBuilder.java b/aclservice/impl/src/test/java/org/opendaylight/netvirt/aclservice/tests/IdentifiedPortSubnetBuilder.java
deleted file mode 100644 (file)
index 401d833..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.aclservice.tests;
-
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.concurrent.NotThreadSafe;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.aclservice.tests.infra.DataTreeIdentifierDataObjectPairBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.PortSubnets;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnet;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@NotThreadSafe
-public class IdentifiedPortSubnetBuilder implements DataTreeIdentifierDataObjectPairBuilder<PortSubnet>  {
-
-    private String newInterfaceName;
-    private final List<SubnetInfo> subnetInfoList = new ArrayList<>();
-
-    @Override
-    public PortSubnet dataObject() {
-        return new PortSubnetBuilder()
-            .withKey(new PortSubnetKey(newInterfaceName))
-            .setPortId(newInterfaceName)
-            .setSubnetInfo(subnetInfoList)
-            .build();
-    }
-
-    @Override
-    public InstanceIdentifier<PortSubnet> identifier() {
-        return InstanceIdentifier.builder(PortSubnets.class)
-                    .child(PortSubnet.class, new PortSubnetKey(newInterfaceName)).build();
-    }
-
-    @Override
-    public LogicalDatastoreType type() {
-        return OPERATIONAL;
-    }
-
-    public IdentifiedPortSubnetBuilder interfaceName(String interfaceName) {
-        this.newInterfaceName = interfaceName;
-        return this;
-    }
-
-    public IdentifiedPortSubnetBuilder addAllSubnetInfo(List<SubnetInfo> addToSubnetInfoList) {
-        this.subnetInfoList.addAll(addToSubnetInfoList);
-        return this;
-    }
-
-}
index de8b558df64771d2312e84d1b429f6802e1cbd36..85564d2bf7b27dd0ce8e1b2f2ec6f3ec39cedcb4 100644 (file)
@@ -819,12 +819,12 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
             interfaceAclBuilder.setPortSecurityEnabled(updatedSecurityEnabled);
             if (updatedSecurityEnabled) {
                 // Handle security group enabled
-                NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, portUpdated);
-                neutronvpnUtils.populateSubnetInfo(portUpdated);
+                neutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, portUpdated);
             } else {
                 // Handle security group disabled
                 interfaceAclBuilder.setSecurityGroups(new ArrayList<>());
                 interfaceAclBuilder.setAllowedAddressPairs(new ArrayList<>());
+                interfaceAclBuilder.setSubnetInfo(new ArrayList<>());
             }
         } else {
             if (updatedSecurityEnabled) {
@@ -843,7 +843,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
 
                 if (portOriginal.getFixedIps() != null
                         && !portOriginal.getFixedIps().equals(portUpdated.getFixedIps())) {
-                    neutronvpnUtils.populateSubnetInfo(portUpdated);
+                    neutronvpnUtils.populateSubnetInfo(interfaceAclBuilder, portUpdated);
                 }
             }
         }
@@ -890,9 +890,8 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         if (NeutronvpnUtils.getPortSecurityEnabled(port)) {
             InterfaceAclBuilder interfaceAclBuilder = new InterfaceAclBuilder();
             interfaceAclBuilder.setPortSecurityEnabled(true);
-            NeutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, port);
+            neutronvpnUtils.populateInterfaceAclBuilder(interfaceAclBuilder, port);
             interfaceBuilder.addAugmentation(InterfaceAcl.class, interfaceAclBuilder.build());
-            neutronvpnUtils.populateSubnetInfo(port);
         }
         return interfaceBuilder.build();
     }
index 8aed1e7b2926794051b72a9e0d403a3399a8b36d..2e7082b90a7732ae348ad766f4afedbb730beb83 100644 (file)
@@ -49,7 +49,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
 import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
@@ -86,15 +85,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev16060
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAclBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpVersionBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.PortSubnets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnet;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.PortSubnetKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.port.subnets.port.subnet.SubnetInfoKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.SubnetInfoKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeFlat;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeGre;
@@ -734,7 +729,7 @@ public class NeutronvpnUtils {
      * @param interfaceAclBuilder the interface acl builder
      * @param port the port
      */
-    protected static void populateInterfaceAclBuilder(InterfaceAclBuilder interfaceAclBuilder, Port port) {
+    protected void populateInterfaceAclBuilder(InterfaceAclBuilder interfaceAclBuilder, Port port) {
         // Handle security group enabled
         List<Uuid> securityGroups = port.getSecurityGroups();
         if (securityGroups != null) {
@@ -750,23 +745,14 @@ public class NeutronvpnUtils {
             aclAllowedAddressPairs.addAll(NeutronvpnUtils.getAllowedAddressPairsForAclService(portAllowedAddressPairs));
         }
         interfaceAclBuilder.setAllowedAddressPairs(aclAllowedAddressPairs);
+
+        populateSubnetInfo(interfaceAclBuilder, port);
     }
 
-    protected void populateSubnetInfo(Port port) {
+    protected void populateSubnetInfo(InterfaceAclBuilder interfaceAclBuilder, Port port) {
         List<SubnetInfo> portSubnetInfo = getSubnetInfo(port);
         if (portSubnetInfo != null) {
-            String portId = port.getUuid().getValue();
-            InstanceIdentifier<PortSubnet> portSubnetIdentifier = buildPortSubnetIdentifier(portId);
-
-            PortSubnetBuilder portSubnetBuilder = new PortSubnetBuilder().withKey(new PortSubnetKey(portId))
-                    .setPortId(portId).setSubnetInfo(portSubnetInfo);
-            try {
-                SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL,
-                        portSubnetIdentifier, portSubnetBuilder.build());
-            } catch (TransactionCommitFailedException e) {
-                LOG.error("Failed to populate subnet info for port={}", portId, e);
-            }
-            LOG.debug("Created Subnet info for port={}", portId);
+            interfaceAclBuilder.setSubnetInfo(portSubnetInfo);
         }
     }
 
@@ -1106,11 +1092,11 @@ public class NeutronvpnUtils {
                 FloatingIpIdToPortMappingKey(floatingIpId)).build();
     }
 
-    static InstanceIdentifier<PortSubnet> buildPortSubnetIdentifier(String portId) {
+    /*static InstanceIdentifier<PortSubnet> buildPortSubnetIdentifier(String portId) {
         InstanceIdentifier<PortSubnet> id = InstanceIdentifier.builder(PortSubnets.class)
                 .child(PortSubnet.class, new PortSubnetKey(portId)).build();
         return id;
-    }
+    }*/
 
     // TODO Remove this method entirely
     @SuppressWarnings("checkstyle:IllegalCatch")