summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2011-06-23 17:39:40 -0500
committerTrey Morris <trey.morris@rackspace.com>2011-06-23 17:39:40 -0500
commitc33fc283c4f75b4de745484b53a818795ad80d96 (patch)
tree68041520608afb077594ec6c2610fb0c6bf5e6cf
parent0bb41eff943b9bb5ba197dc137c3afd93c544398 (diff)
updated the way vifs/fixed_ips are deallocated and their relationships, altered lease/release fixed_ip
-rw-r--r--nova/db/sqlalchemy/api.py5
-rw-r--r--nova/db/sqlalchemy/models.py3
-rw-r--r--nova/network/manager.py26
3 files changed, 14 insertions, 20 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e8cd3fd89..ce8e9f39b 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -675,7 +675,6 @@ def fixed_ip_disassociate(context, address):
address,
session=session)
fixed_ip_ref.instance = None
- fixed_ip_ref.virtual_interface = None
fixed_ip_ref.save(session=session)
@@ -691,7 +690,6 @@ def fixed_ip_disassociate_all_by_timeout(_context, host, time):
filter(models.FixedIp.instance_id != None).\
filter_by(allocated=0).\
update({'instance_id': None,
- 'virtual_interface_id': None,
'leased': 0,
'updated_at': utils.utcnow()},
synchronize_session='fetch')
@@ -953,9 +951,6 @@ def virtual_interface_delete(context, vif_id):
session = get_session()
vif_ref = virtual_interface_get(context, vif_id, session)
with session.begin():
- # disassociate any fixed_ips from this interface
- for fixed_ip in vif_ref['fixed_ips']:
- fixed_ip.virtual_interface = None
session.delete(vif_ref)
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 9e6d6472c..250e88572 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -585,7 +585,10 @@ class FixedIp(BASE, NovaBase):
primaryjoin='and_('
'FixedIp.instance_id == Instance.id,'
'FixedIp.deleted == False)')
+ # associated means that a fixed_ip has its instance_id column set
+ # allocated means that a fixed_ip has a its virtual_interface_id column set
allocated = Column(Boolean, default=False)
+ # leased means dhcp bridge has leased the ip
leased = Column(Boolean, default=False)
reserved = Column(Boolean, default=False)
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 52fe4251a..09350a6a2 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -379,13 +379,13 @@ class NetworkManager(manager.SchedulerDependentManager):
self.db.fixed_ip_get_by_instance(context, instance_id)
LOG.debug(_("network deallocation for instance |%s|"), instance_id,
context=context)
- # deallocate mac addresses
- self.db.virtual_interface_delete_by_instance(context, instance_id)
-
# deallocate fixed ips
for fixed_ip in fixed_ips:
self.deallocate_fixed_ip(context, fixed_ip['address'], **kwargs)
+ # deallocate vifs (mac addresses)
+ self.db.virtual_interface_delete_by_instance(context, instance_id)
+
def get_instance_nw_info(self, context, instance_id, instance_type_id):
"""Creates network info list for instance.
@@ -496,41 +496,37 @@ class NetworkManager(manager.SchedulerDependentManager):
def deallocate_fixed_ip(self, context, address, **kwargs):
"""Returns a fixed ip to the pool."""
- self.db.fixed_ip_update(context, address, {'allocated': False})
+ self.db.fixed_ip_update(context, address,
+ {'allocated': False,
+ 'virtual_interface_id': None})
def lease_fixed_ip(self, context, mac, address):
"""Called by dhcp-bridge when ip is leased."""
- LOG.debug(_('Leasing IP %s'), address, context=context)
+ LOG.debug(_('Leased IP |%s| to mac |%s|'), address, mac,
+ context=context)
fixed_ip = self.db.fixed_ip_get_by_address(context, address)
instance = fixed_ip['instance']
if not instance:
raise exception.Error(_('IP %s leased that is not associated') %
address)
- mac_address = fixed_ip['virtual_interface']['address']
- if mac_address != mac:
- raise exception.Error(_('IP %(address)s leased to bad'
- ' mac %(mac_address)s vs %(mac)s') % locals())
now = utils.utcnow()
self.db.fixed_ip_update(context,
fixed_ip['address'],
{'leased': True,
'updated_at': now})
if not fixed_ip['allocated']:
- LOG.warn(_('IP %s leased that was already deallocated'), address,
+ LOG.warn(_('IP |%s| leased that isn\'t allocated'), address,
context=context)
def release_fixed_ip(self, context, mac, address):
"""Called by dhcp-bridge when ip is released."""
- LOG.debug(_('Releasing IP %s'), address, context=context)
+ LOG.debug(_('Released IP |%s| from mac |%s|'), address, mac,
+ context=context)
fixed_ip = self.db.fixed_ip_get_by_address(context, address)
instance = fixed_ip['instance']
if not instance:
raise exception.Error(_('IP %s released that is not associated') %
address)
- mac_address = fixed_ip['virtual_interface']['address']
- if mac_address != mac:
- raise exception.Error(_('IP %(address)s released from'
- ' bad mac %(mac_address)s vs %(mac)s') % locals())
if not fixed_ip['leased']:
LOG.warn(_('IP %s released that was not leased'), address,
context=context)