cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00960
[Merge] lp:~harlowja/cloud-init/cloud-init-dns-sysconfig into lp:cloud-init
Joshua Harlow has proposed merging lp:~harlowja/cloud-init/cloud-init-dns-sysconfig into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/cloud-init-dns-sysconfig/+merge/297817
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.
--
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/cloud-init-dns-sysconfig into lp:cloud-init.
=== modified file 'cloudinit/net/sysconfig.py'
--- cloudinit/net/sysconfig.py 2016-06-15 23:15:28 +0000
+++ cloudinit/net/sysconfig.py 2016-06-18 01:03:27 +0000
@@ -131,6 +131,7 @@
super(NetInterface, self).__init__()
self.children = []
self.routes = Route(iface_name, base_sysconf_dir)
+ self.last_dns_idx = 0
self._kind = kind
self._iface_name = iface_name
self._conf['DEVICE'] = iface_name
@@ -238,6 +239,13 @@
iface_cfg.name))
if 'netmask' in subnet:
iface_cfg['NETMASK'] = subnet['netmask']
+ if 'dns_nameservers' in subnet:
+ for nameserver in subnet['dns_nameservers']:
+ ns_key = "DNS%s" % iface_cfg.last_dns_idx
+ iface_cfg.last_dns_idx += 1
+ iface_cfg[ns_key] = nameserver
+ if 'dns_search' in subnet:
+ iface_cfg['SEARCH'] = " ".join(subnet['dns_search'])
for route in subnet.get('routes', []):
if _is_default_route(route):
if route_cfg.has_set_default:
@@ -332,13 +340,18 @@
@staticmethod
def _render_dns(network_state, existing_dns_path=None):
content = resolv_conf.ResolvConf("")
+ is_existing = False
if existing_dns_path and os.path.isfile(existing_dns_path):
content = resolv_conf.ResolvConf(util.load_file(existing_dns_path))
+ is_existing = True
for nameserver in network_state.dns_nameservers:
content.add_nameserver(nameserver)
for searchdomain in network_state.dns_searchdomains:
content.add_search_domain(searchdomain)
- return "\n".join([_make_header(';'), str(content)])
+ if is_existing:
+ return str(content)
+ else:
+ return "\n".join([_make_header(';'), str(content)])
@classmethod
def _render_bridge_interfaces(cls, network_state, iface_contents):
Follow ups