summaryrefslogtreecommitdiff
path: root/cloudinit/net/sysconfig.py
diff options
context:
space:
mode:
authorRyan McCabe <rmccabe@redhat.com>2017-11-20 18:16:00 -0500
committerScott Moser <smoser@brickies.net>2017-11-21 10:18:44 -0500
commitbbe91cdc6917adb503b455e6860c21ea7b3f567f (patch)
treeab7051fa7ca8b1ee586c5c3de94868ec7ffeff31 /cloudinit/net/sysconfig.py
parent7624348712b4502f0085d30c05b34dce3f2ceeae (diff)
downloadvyos-cloud-init-bbe91cdc6917adb503b455e6860c21ea7b3f567f.tar.gz
vyos-cloud-init-bbe91cdc6917adb503b455e6860c21ea7b3f567f.zip
sysconfig: Correctly render dns and dns search info.
Currently when dns and dns search info is provided, it is not rendered when outputting to sysconfig format. This patch causes the DNS and DOMAIN lines to be written out rendering sysconfig. LP: #1705804
Diffstat (limited to 'cloudinit/net/sysconfig.py')
-rw-r--r--cloudinit/net/sysconfig.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index f5727969..39d89c46 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -7,12 +7,15 @@ import six
from cloudinit.distros.parsers import networkmanager_conf
from cloudinit.distros.parsers import resolv_conf
+from cloudinit import log as logging
from cloudinit import util
from . import renderer
from .network_state import (
is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6)
+LOG = logging.getLogger(__name__)
+
def _make_header(sep='#'):
lines = [
@@ -347,6 +350,18 @@ class Renderer(renderer.Renderer):
else:
iface_cfg['GATEWAY'] = subnet['gateway']
+ if 'dns_search' in subnet:
+ iface_cfg['DOMAIN'] = ' '.join(subnet['dns_search'])
+
+ if 'dns_nameservers' in subnet:
+ if len(subnet['dns_nameservers']) > 3:
+ # per resolv.conf(5) MAXNS sets this to 3.
+ LOG.debug("%s has %d entries in dns_nameservers. "
+ "Only 3 are used.", iface_cfg.name,
+ len(subnet['dns_nameservers']))
+ for i, k in enumerate(subnet['dns_nameservers'][:3], 1):
+ iface_cfg['DNS' + str(i)] = k
+
@classmethod
def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):