summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorÉdouard Thuleau <edouard.thuleau@orange.com>2012-11-14 18:59:01 +0100
committerÉdouard Thuleau <edouard.thuleau@orange.com>2012-11-29 19:49:37 +0100
commitbdf53c30394f6fc6558d3be52db7166f3796b399 (patch)
tree898554b66618e8df2c201e5617c9c6ebedae6fed /nova/tests
parentb57628a7d3ffbe86be7f9a6e6da763e2aba04af5 (diff)
Multi host DHCP networking and local DNS resolving
Configure all dnsmasq instances to use the hosts file instead of the default local file '/etc/host' when the network is configured in 'multi_host' mode. This hosts file contains all DNS entries of the network and it is replicated on all host where a 'nova-network' daemon is instantiated. There is a hosts file for each networks. It needs to add a new network API to update the host file on all network hosts. When a network host is called to (de)allocate a VM, it (de)allocate the instance fixed IP adress(es) on the concerned network host and when it's done, it calls all networks to update their DNS db entries if it's needed through a fanout cast. DocImpact: new config options Fixes LP bug #1078808 Change-Id: I5c13bd895ebd31f276eb14e996025ddcfb67c3d9
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/fake_network.py2
-rw-r--r--nova/tests/network/test_linux_net.py24
-rw-r--r--nova/tests/network/test_manager.py3
-rw-r--r--nova/tests/network/test_rpcapi.py10
4 files changed, 35 insertions, 4 deletions
diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py
index fc8e4c249..1b96f95dd 100644
--- a/nova/tests/fake_network.py
+++ b/nova/tests/fake_network.py
@@ -24,6 +24,7 @@ from nova.network import api as network_api
from nova.network import manager as network_manager
from nova.network import model as network_model
from nova.network import nova_ipam_lib
+from nova.network import rpcapi as network_rpcapi
from nova.openstack.common import cfg
from nova import utils
from nova.virt.libvirt import config as libvirt_config
@@ -146,6 +147,7 @@ class FakeNetworkManager(network_manager.NetworkManager):
self.db = self.FakeDB()
self.deallocate_called = None
self.deallocate_fixed_ip_calls = []
+ self.network_rpcapi = network_rpcapi.NetworkAPI()
# TODO(matelakat) method signature should align with the faked one's
def deallocate_fixed_ip(self, context, address=None, host=None):
diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py
index 4f94eec95..55a9c7777 100644
--- a/nova/tests/network/test_linux_net.py
+++ b/nova/tests/network/test_linux_net.py
@@ -306,6 +306,24 @@ class LinuxNetworkTestCase(test.TestCase):
self.assertEquals(actual_hosts, expected)
+ def test_get_dns_hosts_for_nw00(self):
+ expected = (
+ "192.168.0.100\tfake_instance00.novalocal\n"
+ "192.168.1.101\tfake_instance01.novalocal\n"
+ "192.168.0.102\tfake_instance00.novalocal"
+ )
+ actual_hosts = self.driver.get_dns_hosts(self.context, networks[0])
+ self.assertEquals(actual_hosts, expected)
+
+ def test_get_dns_hosts_for_nw01(self):
+ expected = (
+ "192.168.1.100\tfake_instance00.novalocal\n"
+ "192.168.0.101\tfake_instance01.novalocal\n"
+ "192.168.1.102\tfake_instance01.novalocal"
+ )
+ actual_hosts = self.driver.get_dns_hosts(self.context, networks[1])
+ self.assertEquals(actual_hosts, expected)
+
def test_get_dhcp_opts_for_nw00(self):
expected_opts = 'NW-3,3\nNW-4,3'
actual_opts = self.driver.get_dhcp_opts(self.context, networks[0])
@@ -333,6 +351,12 @@ class LinuxNetworkTestCase(test.TestCase):
actual = self.driver._host_dhcp(data)
self.assertEquals(actual, expected)
+ def test_host_dns_without_default_gateway_network(self):
+ expected = "192.168.0.100\tfake_instance00.novalocal"
+ data = get_associated(self.context, 0)[0]
+ actual = self.driver._host_dns(data)
+ self.assertEquals(actual, expected)
+
def test_linux_bridge_driver_plug(self):
"""Makes sure plug doesn't drop FORWARD by default.
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index d33b0e582..8d4a511b6 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -1120,7 +1120,8 @@ class CommonNetworkTestCase(test.TestCase):
db.virtual_interface_delete_by_instance = lambda _x, _y: None
ctx = context.RequestContext('igonre', 'igonre')
- db.fixed_ip_get_by_instance = lambda x, y: [dict(address='1.2.3.4')]
+ db.fixed_ip_get_by_instance = lambda x, y: [dict(address='1.2.3.4',
+ network_id='ignoredid')]
manager.deallocate_for_instance(
ctx, instance_id='ignore', host='somehost')
diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py
index 760db7ecb..c31b34a51 100644
--- a/nova/tests/network/test_rpcapi.py
+++ b/nova/tests/network/test_rpcapi.py
@@ -43,10 +43,10 @@ class NetworkRpcAPITestCase(test.TestCase):
args['dest'] = args.pop('dest_compute')
targeted_methods = [
'lease_fixed_ip', 'release_fixed_ip', 'rpc_setup_network_on_host',
- '_rpc_allocate_fixed_ip', 'deallocate_fixed_ip',
+ '_rpc_allocate_fixed_ip', 'deallocate_fixed_ip', 'update_dns',
'_associate_floating_ip', '_disassociate_floating_ip',
- 'lease_fixed_ip', 'release_fixed_ip',
- 'migrate_instance_start', 'migrate_instance_finish',
+ 'lease_fixed_ip', 'release_fixed_ip', 'migrate_instance_start',
+ 'migrate_instance_finish',
]
if method in targeted_methods and 'host' in kwargs:
if method != 'deallocate_fixed_ip':
@@ -250,6 +250,10 @@ class NetworkRpcAPITestCase(test.TestCase):
self._test_network_api('deallocate_fixed_ip', rpc_method='call',
address='fake_addr', host='fake_host')
+ def test_update_dns(self):
+ self._test_network_api('update_dns', rpc_method='fanout_cast',
+ network_ids='fake_id', version='1.3')
+
def test__associate_floating_ip(self):
self._test_network_api('_associate_floating_ip', rpc_method='call',
floating_address='fake_addr', fixed_address='fixed_address',