diff options
| author | Jian Wen <wenjianhn@gmail.com> | 2012-09-21 17:30:18 +0800 |
|---|---|---|
| committer | Jian Wen <wenjianhn@gmail.com> | 2012-10-24 10:22:53 +0800 |
| commit | df1fb2978c854beb58646406796c2bef2bfb047f (patch) | |
| tree | 64fa9d7d86fe49d46dbd69b26b824581a4ef807d /nova/tests | |
| parent | a3d27d189258e2684581bf5e6a1961332e6d44bb (diff) | |
Migrate network of an instance
In multi_host mode, floating ip(s) addr and NAT rules are still on
source node after resize/migrate instance. This patch fixes it up by
adding new methods in network.api to moving them to the destination
node.
Also adds the new methods to network/quantumv2/api.py. They do nothing
but pass for now.
This patch updates network RPC API to version 1.1
Fixes bug 1053344
Change-Id: If9f30050d37831f108ac4a1c8a018d820818f3b6
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/network/test_manager.py | 73 | ||||
| -rw-r--r-- | nova/tests/policy.json | 2 |
2 files changed, 75 insertions, 0 deletions
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index 1ade8bacc..f800581d5 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -1627,6 +1627,79 @@ class FloatingIPTestCase(test.TestCase): self.network.deallocate_for_instance(self.context, instance_id=instance['id']) + def test_migrate_instance_start(self): + called = {'count': 0} + + def fake_floating_ip_get_by_address(context, address): + return {'address': address, + 'fixed_ip_id': 0} + + def fake_is_stale_floating_ip_address(context, floating_ip): + return floating_ip['address'] == '172.24.4.23' + + def fake_fixed_ip_get(context, fixed_ip_id): + return {'instance_uuid': 'fake_uuid', + 'address': '10.0.0.2'} + + def fake_remove_floating_ip(floating_addr, fixed_addr, interface): + called['count'] += 1 + + def fake_floating_ip_update(context, address, args): + pass + + self.stubs.Set(self.network.db, 'floating_ip_get_by_address', + fake_floating_ip_get_by_address) + self.stubs.Set(self.network, '_is_stale_floating_ip_address', + fake_is_stale_floating_ip_address) + self.stubs.Set(self.network.db, 'fixed_ip_get', fake_fixed_ip_get) + self.stubs.Set(self.network.db, 'floating_ip_update', + fake_floating_ip_update) + self.stubs.Set(self.network.l3driver, 'remove_floating_ip', + fake_remove_floating_ip) + self.mox.ReplayAll() + floating_ip_addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] + self.network.migrate_instance_start(self.context, FAKEUUID, + floating_ip_addresses) + + self.assertEqual(called['count'], 2) + + def test_migrate_instance_finish(self): + called = {'count': 0} + + def fake_floating_ip_get_by_address(context, address): + return {'address': address, + 'fixed_ip_id': 0} + + def fake_is_stale_floating_ip_address(context, floating_ip): + return floating_ip['address'] == '172.24.4.23' + + def fake_fixed_ip_get(context, fixed_ip_id): + return {'instance_uuid': 'fake_uuid', + 'address': '10.0.0.2'} + + def fake_add_floating_ip(floating_addr, fixed_addr, interface): + called['count'] += 1 + + def fake_floating_ip_update(context, address, args): + pass + + self.stubs.Set(self.network.db, 'floating_ip_get_by_address', + fake_floating_ip_get_by_address) + self.stubs.Set(self.network, '_is_stale_floating_ip_address', + fake_is_stale_floating_ip_address) + self.stubs.Set(self.network.db, 'fixed_ip_get', fake_fixed_ip_get) + self.stubs.Set(self.network.db, 'floating_ip_update', + fake_floating_ip_update) + self.stubs.Set(self.network.l3driver, 'add_floating_ip', + fake_add_floating_ip) + self.mox.ReplayAll() + floating_ip_addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] + self.network.migrate_instance_finish(self.context, FAKEUUID, + floating_ip_addresses, + 'fake_dest') + + self.assertEqual(called['count'], 2) + def test_floating_dns_create_conflict(self): zone = "example.org" address1 = "10.10.10.11" diff --git a/nova/tests/policy.json b/nova/tests/policy.json index 31b9cefd1..efe2724ad 100644 --- a/nova/tests/policy.json +++ b/nova/tests/policy.json @@ -178,6 +178,8 @@ "network:deallocate_floating_ip": "", "network:associate_floating_ip": "", "network:disassociate_floating_ip": "", + "network:migrate_instance_start": "", + "network:migrate_instance_finish": "", "network:get_fixed_ip": "", "network:get_fixed_ip_by_address": "", |
