18610375 Terminating a VM instance doesn't release floating ip associated with it
authorGirish Moodalbail <Girish.Moodalbail@oracle.COM>
Wed, 16 Apr 2014 18:53:16 -0700
changeset 1832 30ac428a2aaf
parent 1831 2175d25787f8
child 1833 0edb05d72e6b
18610375 Terminating a VM instance doesn't release floating ip associated with it 17975048 'neutron subnet-create' has problems with gateway IPs
components/openstack/neutron/files/evs/plugin.py
--- a/components/openstack/neutron/files/evs/plugin.py	Wed Apr 16 18:14:47 2014 -0700
+++ b/components/openstack/neutron/files/evs/plugin.py	Wed Apr 16 18:53:16 2014 -0700
@@ -16,6 +16,7 @@
 #
 # @author: Girish Moodalbail, Oracle, Inc.
 
+import netaddr
 import rad.client as radcli
 import rad.connect as radcon
 import rad.bindings.com.oracle.solaris.rad.evscntl_1 as evsbind
@@ -269,8 +270,27 @@
                 for i in range(0, len(vlist), 2):
                     hrlist.append({vlist[i]: vlist[i + 1]})
                 subnetdict['host_routes'] = hrlist
-        subnetdict['allocation_pools'] = \
-            [{'start': ipnet.start, 'end': ipnet.end}]
+        # EVS Controller returns a pool that includes gateway_ip as-well,
+        # however neutron expects pool without gateway_ip. So, we determine
+        # the pool ourselves here.
+        assert 'gateway_ip' in subnetdict
+        start_ip = netaddr.IPAddress(ipnet.start)
+        end_ip = netaddr.IPAddress(ipnet.end)
+        gw_ip = netaddr.IPAddress(subnetdict['gateway_ip'])
+        pools = []
+        if gw_ip == start_ip:
+            pools.append({'start' : str(netaddr.IPAddress(start_ip + 1)),
+                          'end': str(netaddr.IPAddress(end_ip))})
+        elif gw_ip == end_ip:
+            pools.append({'start' : str(netaddr.IPAddress(start_ip)),
+                          'end': str(netaddr.IPAddress(end_ip - 1))})
+        else:
+            pools.append({'start': str(netaddr.IPAddress(start_ip)),
+                          'end' : str(netaddr.IPAddress(gw_ip - 1))})
+            pools.append({'start': str(netaddr.IPAddress(gw_ip + 1)),
+                          'end' : str(netaddr.IPAddress(end_ip))})
+
+        subnetdict['allocation_pools'] = pools
         subnetdict['shared'] = False
 
         return subnetdict
@@ -862,6 +882,7 @@
         if l3_port_check:
             self.prevent_l3_port_deletion(context, id)
         try:
+            self.disassociate_floatingips(context, id)
             port = self.get_port(context, id)
             if not port:
                 return