Skip to content

Commit

Permalink
Fix bug 988034 - Quantum Network Manager - not clearing ips
Browse files Browse the repository at this point in the history
Added a line in nova_ipam_lib.QuantumNovaIPAMLib init
method to ensure we clean up IPs and explanation of whats
going on.

Also, nuked release_fixed_ip as that is not
needed in QuantumManager anymore.

Change-Id: I3971b4d4c464ce68ba9370c9f5d8ca7840e0a72a
  • Loading branch information
somikbehera authored and markmc committed Jun 1, 2012
1 parent 4aea7f1 commit 3426030
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -172,6 +172,7 @@ Salvatore Orlando <salvatore.orlando@eu.citrix.com>
Sandy Walsh <sandy.walsh@rackspace.com>
Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
Scott Moser <smoser@ubuntu.com>
Somik Behera <somikbehera@gmail.com>
Soren Hansen <soren.hansen@rackspace.com>
Stanislaw Pitucha <stanislaw.pitucha@hp.com>
Stephanie Reese <reese.sm@gmail.com>
Expand Down
8 changes: 0 additions & 8 deletions nova/network/quantum/manager.py
Expand Up @@ -668,14 +668,6 @@ def validate_networks(self, context, networks):
if not (is_tenant_net or is_provider_net):
raise exception.NetworkNotFound(network_id=net_id)

# NOTE(bgh): deallocate_for_instance will take care of this.. The reason
# we're providing this is so that NetworkManager::release_fixed_ip() isn't
# called. It does some database operations that we don't want to happen
# and since the majority of the stuff that it does is already taken care
# of in our deallocate_for_instance call we don't need to do anything.
def release_fixed_ip(self, context, address):
pass

def get_dhcp_hosts_text(self, context, subnet_id, project_id=None):
ips = self.ipam.get_allocated_ips(context, subnet_id, project_id)
hosts_text = ""
Expand Down
15 changes: 15 additions & 0 deletions nova/network/quantum/nova_ipam_lib.py
Expand Up @@ -47,6 +47,10 @@ 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 @@ -213,6 +217,17 @@ def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
admin_context = context.elevated()
fixed_ips = db.fixed_ips_by_virtual_interface(admin_context,
vif_ref['id'])
# NOTE(s0mik): Sets fixed-ip to deallocated, but leaves the entry
# associated with the instance-id. This prevents us from handing it
# out again immediately, as allocating it to a new instance before
# a DHCP lease has timed-out is bad. Instead, the fixed-ip will
# 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.
for fixed_ip in fixed_ips:
db.fixed_ip_update(admin_context, fixed_ip['address'],
{'allocated': False,
Expand Down

0 comments on commit 3426030

Please sign in to comment.