From 4e7bb008effe92a4e06a2d104cbd1ea0d19a5db6 Mon Sep 17 00:00:00 2001
From: Troy Toman
Date: 2012年7月13日 17:22:23 -0500
Subject: [PATCH] bug 1024557
De-dupes the list of DNS IPs that is put in the xenstore for network configuration
Added a duplicate DNS IP in the fake_network to create a valid test.
Change-Id: I25a00c7e47578b1667992aa4bad879667198465a
---
nova/tests/fake_network.py | 1 +
nova/tests/test_xenapi.py | 2 +-
nova/virt/xenapi/vmops.py | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py
index 5391da4179ac..b120dc9b1409 100644
--- a/nova/tests/fake_network.py
+++ b/nova/tests/fake_network.py
@@ -174,6 +174,7 @@ def fake_network(network_id, ipv6=None):
'broadcast': '192.168.%d.255' % network_id,
'dns1': '192.168.%d.3' % network_id,
'dns2': '192.168.%d.4' % network_id,
+ 'dns3': '192.168.%d.3' % network_id,
'vlan': None,
'host': None,
'project_id': 'fake_project',
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index f05ea9e5b8a9..e1e3604163f1 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -435,7 +435,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
tcpip_data = ast.literal_eval(xenstore_value)
self.assertEquals(tcpip_data,
{'broadcast': '192.168.1.255',
- 'dns': ['192.168.1.3', '192.168.1.4'],
+ 'dns': ['192.168.1.4', '192.168.1.3'],
'gateway': '192.168.1.1',
'gateway_v6': 'fe80::def',
'ip6s': [{'enabled': '1',
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index f9958ff4c000..687ec0b653a6 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1265,7 +1265,7 @@ class VMOps(object):
info_dict['routes'] = routes
if dns:
- info_dict['dns'] = dns
+ info_dict['dns'] = list(set(dns))
return info_dict