Skip to content

Commit

Permalink
Stop nova_ipam_lib from changing the timeout setting
Browse files Browse the repository at this point in the history
 * Fixes incorrect logic for when timeout should be used. We
   want to timeout along with dhcp, and release immediately
   without dhcp
 * Also makes ipam_lib release fixed_ips after floating ips, as
   this is the way that the internal network managers do it.
 * Fixes bug 1014769

Change-Id: I687fac314264b8a89da128ed77c02d9b1ca140ff
  • Loading branch information
vishvananda committed Jun 26, 2012
1 parent 1a169b8 commit 45e98d4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions nova/network/quantum/nova_ipam_lib.py
Expand Up @@ -47,10 +47,6 @@ def __init__(self, net_manager):
"""
self.net_manager = net_manager

# NOTE(s0mik) : If DHCP is not in use, we need to timeout IPs
# periodically. See comment in deallocate_ips_by_vif for more
self.net_manager.timeout_fixed_ips = not self.net_manager.DHCP

def create_subnet(self, context, label, tenant_id,
quantum_net_id, priority, cidr=None,
gateway=None, gateway_v6=None, cidr_v6=None,
Expand Down Expand Up @@ -224,16 +220,12 @@ def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
# be disassociated with the instance-id by a call to one of two
# methods inherited from FlatManager:
# - if DHCP is in use, a lease expiring in dnsmasq triggers
# a call to release_fixed_ip in the network manager.
# - otherwise, _disassociate_stale_fixed_ips is called periodically
# to disassociate all fixed ips that are unallocated
# but still associated with an instance-id.
# a call to release_fixed_ip in the network manager, or it will
# be timed out periodically if the lease fails.
# - otherwise, we release the ip immediately

read_deleted_context = admin_context.elevated(read_deleted='yes')
for fixed_ip in fixed_ips:
db.fixed_ip_update(admin_context, fixed_ip['address'],
{'allocated': False,
'virtual_interface_id': None})
fixed_id = fixed_ip['id']
floating_ips = self.net_manager.db.floating_ip_get_by_fixed_ip_id(
admin_context,
Expand All @@ -252,6 +244,11 @@ def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
read_deleted_context,
address,
affect_auto_assigned=True)
db.fixed_ip_update(admin_context, fixed_ip['address'],
{'allocated': False,
'virtual_interface_id': None})
if not self.net_manager.DHCP:
db.fixed_ip_disassociate(admin_context, fixed_ip['address'])

if len(fixed_ips) == 0:
LOG.error(_('No fixed IPs to deallocate for vif %s'),
Expand Down

0 comments on commit 45e98d4

Please sign in to comment.