Merge lp:~harlowja/cloud-init/cloud-init-dns-sysconfig into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Rejected
Rejected by: Scott Moser
Proposed branch: lp:~harlowja/cloud-init/cloud-init-dns-sysconfig
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 71 lines (+23/-2)
1 file modified
cloudinit/net/sysconfig.py (+23/-2)
To merge this branch: bzr merge lp:~harlowja/cloud-init/cloud-init-dns-sysconfig
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+297817@code.launchpad.net

Description of the change

It appears that 'dns_nameservers' and 'dns_search' can be a per subnet/iface specification and the eni renderer actually handles this so make an attempt to in the sysconfig renderer as well.

To post a comment you must log in.
1244. By Joshua Harlow

Ensure dns indexes are shared among subinterfaces

Revision history for this message
Ryan Harper (raharper) wrote :

This is fairly forward looking. Depending on the OS support for this sort of thing, it's certainly desirable for users to want to say things like "send queries to this server out this interface" however, I don't know of an OS that does this without more configuration elsewhere on the system.

For example, on Debian/Ubuntu, resolvconf and glibc certainly aren't doing this by default. One can imagine a more sophisticated bind or dnsmasq configuration but we're not doing that at this time.

Revision history for this message
Joshua Harlow (harlowja) wrote :

Ya, I had a hard time finding out how to make it so that each interface could have its own dns server and such configuration; it really seems like not many systems allow for doing this very well...

Revision history for this message
Joshua Harlow (harlowja) :
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Hello,
Thank you for taking the time to contribute to cloud-init. Cloud-init has moved its revision control system to git. As a result, we are marking all bzr merge proposals as 'rejected'. If you would like to re-submit this proposal for review, please do so by following the current HACKING documentation at http://cloudinit.readthedocs.io/en/latest/topics/hacking.html .

Unmerged revisions

1244. By Joshua Harlow

Ensure dns indexes are shared among subinterfaces

1243. By Joshua Harlow

Add sysconfig 'dns_nameservers' and 'dns_search' per interface/subnet handling

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/net/sysconfig.py'
2--- cloudinit/net/sysconfig.py 2016-06-15 23:15:28 +0000
3+++ cloudinit/net/sysconfig.py 2016-06-18 01:07:35 +0000
4@@ -116,6 +116,11 @@
5 'name': self._route_name})
6
7
8+class _SharedInt(object):
9+ def __init__(self):
10+ self.value = 0
11+
12+
13 class NetInterface(ConfigMap):
14 """Represents a sysconfig/networking-script (and its config + children)."""
15
16@@ -131,6 +136,7 @@
17 super(NetInterface, self).__init__()
18 self.children = []
19 self.routes = Route(iface_name, base_sysconf_dir)
20+ self.last_dns_idx = _SharedInt()
21 self._kind = kind
22 self._iface_name = iface_name
23 self._conf['DEVICE'] = iface_name
24@@ -160,9 +166,12 @@
25 return self.iface_fn_tpl % ({'base': self._base_sysconf_dir,
26 'name': self.name})
27
28- def copy(self, copy_children=False, copy_routes=False):
29+ def copy(self, copy_children=False, copy_routes=False,
30+ share_dns_idx=True):
31 c = NetInterface(self.name, self._base_sysconf_dir, kind=self._kind)
32 c._conf = self._conf.copy()
33+ if share_dns_idx:
34+ c.last_dns_idx = self.last_dns_idx
35 if copy_children:
36 c.children = list(self.children)
37 if copy_routes:
38@@ -238,6 +247,13 @@
39 iface_cfg.name))
40 if 'netmask' in subnet:
41 iface_cfg['NETMASK'] = subnet['netmask']
42+ if 'dns_nameservers' in subnet:
43+ for nameserver in subnet['dns_nameservers']:
44+ ns_key = "DNS%s" % iface_cfg.last_dns_idx.value
45+ iface_cfg.last_dns_idx.value += 1
46+ iface_cfg[ns_key] = nameserver
47+ if 'dns_search' in subnet:
48+ iface_cfg['SEARCH'] = " ".join(subnet['dns_search'])
49 for route in subnet.get('routes', []):
50 if _is_default_route(route):
51 if route_cfg.has_set_default:
52@@ -332,13 +348,18 @@
53 @staticmethod
54 def _render_dns(network_state, existing_dns_path=None):
55 content = resolv_conf.ResolvConf("")
56+ is_existing = False
57 if existing_dns_path and os.path.isfile(existing_dns_path):
58 content = resolv_conf.ResolvConf(util.load_file(existing_dns_path))
59+ is_existing = True
60 for nameserver in network_state.dns_nameservers:
61 content.add_nameserver(nameserver)
62 for searchdomain in network_state.dns_searchdomains:
63 content.add_search_domain(searchdomain)
64- return "\n".join([_make_header(';'), str(content)])
65+ if is_existing:
66+ return str(content)
67+ else:
68+ return "\n".join([_make_header(';'), str(content)])
69
70 @classmethod
71 def _render_bridge_interfaces(cls, network_state, iface_contents):