yang model revise: neutron-subnets.yang 40/35840/8
authorIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 4 Mar 2016 06:34:26 +0000 (22:34 -0800)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 08:37:24 +0000 (01:37 -0700)
This patch revises neutron-subnet yang model and related codes.
- updates type. string -> inet:ip-address
- removes deprecated SPI methods
- removes backpointers in subnets. ports in subnet

Change-Id: Ie85dcd526db72b308c24b345fd6c1036e04b2d82
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
model/src/main/yang/neutron-subnets.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSubnetCRUD.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSubnetInterface.java

index bc4f53ad7d014fa2a467345d97c820ac1e3b51b9..a19a870c16c68cc06f0623b8d02c55069377dbe0 100644 (file)
@@ -42,7 +42,7 @@ module neutron-subnets {
             }
         }
         leaf cidr {
-            type string;
+            type inet:ip-prefix;
             description "cidr representing IP range for this subnet, based on IP version";
         }
         leaf gateway-ip {
@@ -80,10 +80,10 @@ module neutron-subnets {
             description "Sub-ranges of cidr available for dynamic allocation to ports";
             key start;
             leaf start {
-                type string;
+                type inet:ip-address;
             }
             leaf end {
-                type string;
+                type inet:ip-address;
             }
         }
         list host-routes {
index 18e7571603810befe14edca92c1fc4d59a89b8e3..9f5f0f25849c18b9a2b5e549e6ee81f26346360e 100644 (file)
@@ -81,18 +81,4 @@ public interface INeutronSubnetCRUD
      */
 
     boolean updateSubnet(String uuid, NeutronSubnet delta);
-
-    /**
-     * Applications call this interface method to determine if a Subnet object
-     * is use
-     *
-     * @param subnetUUID
-     *            identifier of the subnet object
-     *
-     * @return boolean on whether the subnet is in use or not
-     *
-     * @deprecated - will be removed in Boron
-     */
-
-    boolean subnetInUse(String subnetUUID);
 }
index e095bc061320c118e42ac44ff71b76273191f76d..fac4b747330c378b4e8f1d8266792d056400dac5 100644 (file)
@@ -79,33 +79,6 @@ public class NeutronSubnet extends NeutronObject implements Serializable, INeutr
     @XmlElement (name = "ipv6_ra_mode", nillable = true)
     String ipV6RaMode;
 
-    /* stores the OpenStackPorts associated with an instance
-     * used to determine if that instance can be deleted.
-     *
-     * @deprecated, will be removed in Boron
-     */
-
-    List<NeutronPort> myPorts;
-
-    public NeutronSubnet() {
-        myPorts = new ArrayList<NeutronPort>();
-    }
-
-    // @deprecated - will be removed in Boron
-    public void setPorts(List<NeutronPort> arg) {
-        myPorts = arg;
-    }
-
-    @Deprecated
-    public String getSubnetUUID() {
-        return getID();
-    }
-
-    @Deprecated
-    public void setSubnetUUID(String uuid) {
-        setID(uuid);
-    }
-
     public String getNetworkUUID() {
         return networkUUID;
     }
@@ -255,22 +228,6 @@ public class NeutronSubnet extends NeutronObject implements Serializable, INeutr
         return ans;
     }
 
-    // @deprecated - will be removed in Boron
-    public List<NeutronPort> getPortsInSubnet() {
-        return myPorts;
-    }
-
-    // @deprecated - will be removed in Boron
-    public List<NeutronPort> getPortsInSubnet(String ignore) {
-       List<NeutronPort> answer = new ArrayList<NeutronPort>();
-       for (NeutronPort port : myPorts) {
-           if (!port.getDeviceOwner().equalsIgnoreCase(ignore)) {
-                answer.add(port);
-            }
-        }
-        return answer;
-    }
-
     /* test to see if the cidr address used to define this subnet
      * is a valid network address (an necessary condition when creating
      * a new subnet)
index 4dd041e18a1929caadf45993381aa075306c894f..d20247a3a363bcccf4849fb9ff8aed6056365b8c 100644 (file)
@@ -9,21 +9,15 @@
 package org.opendaylight.neutron.transcriber;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
-
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.Neutron_IPs;
-import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
-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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
 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;
@@ -51,10 +45,13 @@ import com.google.common.collect.ImmutableBiMap;
 public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Subnets, NeutronSubnet> implements INeutronSubnetCRUD {
     private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSubnetInterface.class);
 
+    private static final int IPV4_VERSION = 4;
+    private static final int IPV6_VERSION = 6;
+
     private static final ImmutableBiMap<Class<? extends IpVersionBase>,Integer> IPV_MAP
             = new ImmutableBiMap.Builder<Class<? extends IpVersionBase>,Integer>()
-            .put(IpVersionV4.class,Integer.valueOf(4))
-            .put(IpVersionV6.class,Integer.valueOf(6))
+            .put(IpVersionV4.class,Integer.valueOf(IPV4_VERSION))
+            .put(IpVersionV6.class,Integer.valueOf(IPV6_VERSION))
             .build();
 
     private static final ImmutableBiMap<Class<? extends Dhcpv6Base>,String> DHCPV6_MAP
@@ -109,19 +106,13 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
         return update(uuid, delta);
     }
 
-// note: this is being set to false in preparation for deprecation and removal
-    @Override
-    public boolean subnetInUse(String subnetUUID) {
-        return false;
-    }
-
     protected NeutronSubnet fromMd(Subnet subnet) {
         final NeutronSubnet result = new NeutronSubnet();
         result.setName(subnet.getName());
         result.setTenantID(subnet.getTenantId());
         result.setNetworkUUID(subnet.getNetworkId().getValue());
         result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
-        result.setCidr(subnet.getCidr());
+        result.setCidr(String.valueOf(subnet.getCidr().getValue()));
         if (subnet.getGatewayIp() != null) {
             result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));
         }
@@ -136,8 +127,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
             final List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<NeutronSubnetIPAllocationPool>();
             for (final AllocationPools allocationPool : subnet.getAllocationPools()) {
                 final NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
-                pool.setPoolStart(allocationPool.getStart());
-                pool.setPoolEnd(allocationPool.getEnd());
+                pool.setPoolStart(String.valueOf(allocationPool.getStart().getValue()));
+                pool.setPoolEnd(String.valueOf(allocationPool.getEnd().getValue()));
                 allocationPools.add(pool);
             }
             result.setAllocationPools(allocationPools);
@@ -160,25 +151,6 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
             result.setHostRoutes(hostRoutes);
         }
         result.setID(subnet.getUuid().getValue());
-// read through the ports and put the ones in this subnet into the internal
-// myPorts object.
-// @deprecated and will be removed in Boron
-        final Set<NeutronPort> allPorts = new HashSet<NeutronPort>();
-        final NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
-            .fetchINeutronPortCRUD(this);
-        final INeutronPortCRUD portIf = interfaces.getPortInterface();
-        for (final NeutronPort port : portIf.getAllPorts()) {
-            if (port.getFixedIPs() != null) {
-                for (final Neutron_IPs ip : port.getFixedIPs()) {
-                    if (ip.getSubnetUUID().equals(result.getID())) {
-                        allPorts.add(port);
-                    }
-                }
-            }
-        }
-        final List<NeutronPort> ports = new ArrayList<NeutronPort>();
-        ports.addAll(allPorts);
-        result.setPorts(ports);
         return result;
     }
 
@@ -200,7 +172,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
                     .getIpVersion()));
         }
         if (subnet.getCidr() != null) {
-            subnetBuilder.setCidr(subnet.getCidr());
+            final IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(subnet.getCidr());
+            subnetBuilder.setCidr(ipPrefix);
         }
         if (subnet.getGatewayIP() != null) {
             final IpAddress ipAddress = new IpAddress(subnet.getGatewayIP()
@@ -223,8 +196,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Sub
             for (final NeutronSubnetIPAllocationPool allocationPool : subnet
                     .getAllocationPools()) {
                 final AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
-                builder.setStart(allocationPool.getPoolStart());
-                builder.setEnd(allocationPool.getPoolEnd());
+                builder.setStart(new IpAddress(allocationPool.getPoolStart().toCharArray()));
+                builder.setEnd(new IpAddress(allocationPool.getPoolEnd().toCharArray()));
                 final AllocationPools temp = builder.build();
                 allocationPools.add(temp);
             }