Merge "Make floating_ips module use FloatingIP for updates"

This commit is contained in:
Jenkins
2014-02-19 04:10:46 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 18 deletions

View File

@@ -566,9 +566,8 @@ class FloatingIP(object):
# NOTE(wenjianhn): Make this address will not be bound to public # NOTE(wenjianhn): Make this address will not be bound to public
# interface when restarts nova-network on dest compute node # interface when restarts nova-network on dest compute node
self.db.floating_ip_update(context, floating_ip.host = None
floating_ip.address, floating_ip.save()
{'host': None})
def migrate_instance_finish(self, context, instance_uuid, def migrate_instance_finish(self, context, instance_uuid,
floating_addresses, host=None, floating_addresses, host=None,
@@ -595,9 +594,8 @@ class FloatingIP(object):
{'address': address, 'instance_uuid': instance_uuid}) {'address': address, 'instance_uuid': instance_uuid})
continue continue
self.db.floating_ip_update(context, floating_ip.host = dest
floating_ip.address, floating_ip.save()
{'host': dest})
interface = CONF.public_interface or floating_ip.interface interface = CONF.public_interface or floating_ip.interface
fixed_ip = floating_ip.fixed_ip fixed_ip = floating_ip.fixed_ip

View File

@@ -2369,7 +2369,9 @@ class FloatingIPTestCase(test.TestCase):
@mock.patch('nova.db.fixed_ip_get') @mock.patch('nova.db.fixed_ip_get')
@mock.patch('nova.db.floating_ip_get_by_address') @mock.patch('nova.db.floating_ip_get_by_address')
def test_migrate_instance_start(self, floating_get, fixed_get): @mock.patch('nova.db.floating_ip_update')
def test_migrate_instance_start(self, floating_update, floating_get,
fixed_get):
called = {'count': 0} called = {'count': 0}
def fake_floating_ip_get_by_address(context, address): def fake_floating_ip_get_by_address(context, address):
@@ -2385,6 +2387,8 @@ class FloatingIPTestCase(test.TestCase):
instance_uuid='fake_uuid', instance_uuid='fake_uuid',
address='10.0.0.2', address='10.0.0.2',
network=test_network.fake_network) network=test_network.fake_network)
floating_update.return_value = fake_floating_ip_get_by_address(
None, '1.2.3.4')
def fake_remove_floating_ip(floating_addr, fixed_addr, interface, def fake_remove_floating_ip(floating_addr, fixed_addr, interface,
network): network):
@@ -2394,13 +2398,8 @@ class FloatingIPTestCase(test.TestCase):
if not str(fixed_ip) == "10.0.0.2": if not str(fixed_ip) == "10.0.0.2":
raise exception.FixedIpInvalid(address=fixed_ip) raise exception.FixedIpInvalid(address=fixed_ip)
def fake_floating_ip_update(context, address, args):
pass
self.stubs.Set(self.network, '_is_stale_floating_ip_address', self.stubs.Set(self.network, '_is_stale_floating_ip_address',
fake_is_stale_floating_ip_address) fake_is_stale_floating_ip_address)
self.stubs.Set(self.network.db, 'floating_ip_update',
fake_floating_ip_update)
self.stubs.Set(self.network.l3driver, 'remove_floating_ip', self.stubs.Set(self.network.l3driver, 'remove_floating_ip',
fake_remove_floating_ip) fake_remove_floating_ip)
self.stubs.Set(self.network.l3driver, 'clean_conntrack', self.stubs.Set(self.network.l3driver, 'clean_conntrack',
@@ -2418,7 +2417,8 @@ class FloatingIPTestCase(test.TestCase):
self.assertEqual(called['count'], 2) self.assertEqual(called['count'], 2)
@mock.patch('nova.db.fixed_ip_get') @mock.patch('nova.db.fixed_ip_get')
def test_migrate_instance_finish(self, fixed_get): @mock.patch('nova.db.floating_ip_update')
def test_migrate_instance_finish(self, floating_update, fixed_get):
called = {'count': 0} called = {'count': 0}
def fake_floating_ip_get_by_address(context, address): def fake_floating_ip_get_by_address(context, address):
@@ -2433,20 +2433,17 @@ class FloatingIPTestCase(test.TestCase):
instance_uuid='fake_uuid', instance_uuid='fake_uuid',
address='10.0.0.2', address='10.0.0.2',
network=test_network.fake_network) network=test_network.fake_network)
floating_update.return_value = fake_floating_ip_get_by_address(
None, '1.2.3.4')
def fake_add_floating_ip(floating_addr, fixed_addr, interface, def fake_add_floating_ip(floating_addr, fixed_addr, interface,
network): network):
called['count'] += 1 called['count'] += 1
def fake_floating_ip_update(context, address, args):
pass
self.stubs.Set(self.network.db, 'floating_ip_get_by_address', self.stubs.Set(self.network.db, 'floating_ip_get_by_address',
fake_floating_ip_get_by_address) fake_floating_ip_get_by_address)
self.stubs.Set(self.network, '_is_stale_floating_ip_address', self.stubs.Set(self.network, '_is_stale_floating_ip_address',
fake_is_stale_floating_ip_address) fake_is_stale_floating_ip_address)
self.stubs.Set(self.network.db, 'floating_ip_update',
fake_floating_ip_update)
self.stubs.Set(self.network.l3driver, 'add_floating_ip', self.stubs.Set(self.network.l3driver, 'add_floating_ip',
fake_add_floating_ip) fake_add_floating_ip)
self.mox.ReplayAll() self.mox.ReplayAll()