Default DNS servers for servers in Neutron network

Add default DNS server (Google's one) for the Servers created inside
Neutron network.

Change-Id: Id6e799056b70fd3ae11f196fb3eb55fa1e3f204d
This commit is contained in:
Pavel Boldin 2015-02-26 13:11:45 +02:00
parent f41531e60c
commit 99a7a1e6d9
3 changed files with 16 additions and 5 deletions

View File

@ -241,7 +241,9 @@ class NeutronWrapper(NetworkWrapper):
network_args = {
"network": {
"tenant_id": tenant_id,
"name": utils.generate_random_name("rally_net_")}}
"name": utils.generate_random_name("rally_net_")
}
}
network = self.client.create_network(network_args)["network"]
router = None
@ -258,7 +260,11 @@ class NeutronWrapper(NetworkWrapper):
"name": utils.generate_random_name("rally_subnet_"),
"ip_version": self.SUBNET_IP_VERSION,
"cidr": self._generate_cidr(),
"enable_dhcp": True}}
"enable_dhcp": True,
"dns_nameservers": kwargs.get("dns_nameservers",
["8.8.8.8", "8.8.4.4"])
}
}
subnet = self.client.create_subnet(subnet_args)["subnet"]
subnets.append(subnet["id"])

View File

@ -259,6 +259,7 @@ class NeutronWrapperTestCase(test.TestCase):
"network_id": "foo_id",
"tenant_id": "foo_tenant",
"ip_version": service.SUBNET_IP_VERSION,
"dns_nameservers": ["8.8.8.8", "8.8.4.4"],
"cidr": "cidr-%d" % i}})
for i in range(subnets_num)])
@ -296,7 +297,8 @@ class NeutronWrapperTestCase(test.TestCase):
"name": "foo_name",
"status": "foo_status"}}
net = service.create_network("foo_tenant", add_router=True,
subnets_num=subnets_num)
subnets_num=subnets_num,
dns_nameservers=["foo_nameservers"])
self.assertEqual(net, {"id": "foo_id",
"name": "foo_name",
"status": "foo_status",
@ -313,6 +315,7 @@ class NeutronWrapperTestCase(test.TestCase):
"network_id": "foo_id",
"tenant_id": "foo_tenant",
"ip_version": service.SUBNET_IP_VERSION,
"dns_nameservers": ["foo_nameservers"],
"cidr": "foo_cidr"}})] * subnets_num)
self.assertEqual(service.client.add_interface_router.mock_calls,
[mock.call("foo_router", {"subnet_id": "foo_subnet"})

View File

@ -1084,7 +1084,10 @@ class FakeNeutronClient(object):
def create_subnet(self, data):
subnet = setup_dict(data["subnet"],
required=["network_id", "cidr", "ip_version"],
defaults={"name": generate_name("subnet_")})
defaults={
"name": generate_name("subnet_"),
"dns_nameservers": ["8.8.8.8", "8.8.4.4"]
})
if subnet["network_id"] not in self.__networks:
raise neutron_exceptions.NeutronClientException
@ -1092,7 +1095,6 @@ class FakeNeutronClient(object):
subnet.update({"id": subnet_id,
"enable_dhcp": True,
"tenant_id": self.__tenant_id,
"dns_nameservers": [],
"ipv6_ra_mode": None,
"allocation_pools": [],
"gateway_ip": re.sub("./.*$", "1", subnet["cidr"]),