Bug 4805 add host_routes info to MDSAL 79/31579/4
authorVishal Thapar <vishal.thapar@ericsson.com>
Thu, 17 Dec 2015 20:50:23 +0000 (02:20 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Tue, 22 Dec 2015 04:46:14 +0000 (10:16 +0530)
Transcriber is missing code to add hostRoute information to
MDSAL when Subnet is created/updated.

This change adds code to toMd() and fromMd() to handle hostRoutes.

Change-Id: I7b7b7dc5092971d86aec38e5365518712d84e8c2
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronSubnetTests.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet_HostRoute.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSubnetInterface.java

index 9fb102b6cea53bf55b1a6f120604d606df3888fd..5c6b2c593284be67b61f6b44ce58fcb8054f198b 100644 (file)
@@ -37,12 +37,12 @@ public class NeutronSubnetTests {
             "\"enable_dhcp\": true, "+
             "\"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "+
             "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "+
-            "\"dns_nameservers\": [], "+
+            "\"dns_nameservers\": [\"8.8.8.8\"], "+
             "\"allocation_pools\": [ { "+
                 "\"start\": \"10.0.0.2\", "+
                 "\"end\": \"10.0.0.254\" } ], "+
             "\"host_routes\":[ { \"destination\":\"0.0.0.0/0\", " +
-               " \"nexthop\":\"123.456.78.9\" }, " +
+               " \"nexthop\":\"123.156.78.9\" }, " +
             " { \"destination\":\"192.168.0.0/24\", " +
                " \"nexthop\":\"192.168.0.1\" } ], " +
             "\"ip_version\": 4, "+
index 38cd3b0c1cf21129e0bb9db1b0b89b8170cab654..70bf1027ebff531aada22fd1ace6b8642c691144 100644 (file)
@@ -34,6 +34,22 @@ public class NeutronSubnet_HostRoute implements Serializable {
      */
     public NeutronSubnet_HostRoute() { }
 
+    public String getDestination() {
+        return destination;
+    }
+
+    public void setDestination(String destination) {
+        this.destination = destination;
+    }
+
+    public String getNextHop() {
+        return nextHop;
+    }
+
+    public void setNextHop(String nextHop) {
+        this.nextHop = nextHop;
+    }
+
     @Override
     public String toString() {
         return "NeutronSubnetHostRoute [" +
index 973be6e9ab6527b11e4c083c09e458529165bd57..061718b69b2527339f738fe700a459278d367169 100644 (file)
@@ -23,8 +23,10 @@ import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
 import org.opendaylight.neutron.spi.NeutronNetwork;
 import org.opendaylight.neutron.spi.NeutronPort;
 import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.neutron.spi.NeutronSubnet_HostRoute;
 import org.opendaylight.neutron.spi.NeutronSubnetIPAllocationPool;
 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.rev100924.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Base;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Off;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Slaac;
@@ -36,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.AllocationPools;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.AllocationPoolsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.HostRoutes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.HostRoutesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetBuilder;
@@ -164,6 +168,16 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
             }
             result.setDnsNameservers(dnsNameServers);
         }
+        if(subnet.getHostRoutes() != null){
+            List<NeutronSubnet_HostRoute> hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+            for(HostRoutes hostRoute : subnet.getHostRoutes()) {
+                NeutronSubnet_HostRoute nsHostRoute = new NeutronSubnet_HostRoute();
+                nsHostRoute.setDestination(String.valueOf(hostRoute.getDestination().getValue()));
+                nsHostRoute.setNextHop(String.valueOf(hostRoute.getNexthop().getValue()));
+                hostRoutes.add(nsHostRoute);
+            }
+            result.setHostRoutes(hostRoutes);
+        }
         result.setID(subnet.getUuid().getValue());
 // read through the ports and put the ones in this subnet into the internal
 // myPorts object.
@@ -243,6 +257,16 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
             }
             subnetBuilder.setDnsNameservers(dnsNameServers);
         }
+        if(subnet.getHostRoutes() != null) {
+            List<HostRoutes> hostRoutes = new ArrayList<HostRoutes>();
+            for(NeutronSubnet_HostRoute hostRoute: subnet.getHostRoutes()) {
+                HostRoutesBuilder hrBuilder = new HostRoutesBuilder();
+                hrBuilder.setDestination(new IpPrefix(hostRoute.getDestination().toCharArray()));
+                hrBuilder.setNexthop(new IpAddress(hostRoute.getNextHop().toCharArray()));
+                hostRoutes.add(hrBuilder.build());
+            }
+            subnetBuilder.setHostRoutes(hostRoutes);
+        }
         if (subnet.getID() != null) {
             subnetBuilder.setUuid(toUuid(subnet.getID()));
         } else {