diff options
author | Michael Still <mikal@stillhq.com> | 2019-02-25 04:13:33 +0000 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2019-08-16 11:24:22 +0100 |
commit | 6e563d97030a960c1f042d2b908b4aa94ef214e1 (patch) | |
tree | 1828b381c4641415f0da25f3619f8e13c8936dfe /nova/privsep | |
parent | 54bf4694b9057264ebf49a299478b4fd325fafb7 (diff) | |
download | nova-6e563d97030a960c1f042d2b908b4aa94ef214e1.tar.gz |
Move dnsmasq restarts to privsep.
I don't really love this one, but I don't see a better way to
untangle this.
Change-Id: Icce18320a7c8fba3cf06bd032fbbe1846804e897
Diffstat (limited to 'nova/privsep')
-rw-r--r-- | nova/privsep/linux_net.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/nova/privsep/linux_net.py b/nova/privsep/linux_net.py index 90172c1c6a..06bfa1488c 100644 --- a/nova/privsep/linux_net.py +++ b/nova/privsep/linux_net.py @@ -289,3 +289,54 @@ def iptables_set_rules(rules, ipv4=True): processutils.execute('%s-restore' % cmd, '-c', process_input=six.b('\n'.join(rules)), attempts=5) + + +@nova.privsep.sys_admin_pctxt.entrypoint +def restart_dnsmasq(flag_file, network_ref, config_file, pid_path, opts_path, + dhcp_lease_time, lease_max, conf_path, dhcp_bridge, + dhcp_domain, dns_servers, hosts_path): + _restart_dnsmasq_inner(flag_file, network_ref, config_file, pid_path, + opts_path, dhcp_lease_time, lease_max, conf_path, + dhcp_bridge, dhcp_domain, dns_servers, hosts_path) + + +# NOTE(mikal): this is done like this to enable unit testing +def _restart_dnsmasq_inner(flag_file, network_ref, config_file, pid_path, + opts_path, dhcp_lease_time, lease_max, conf_path, + dhcp_bridge, dhcp_domain, dns_servers, hosts_path): + cmd = ['env', + 'CONFIG_FILE=%s' % flag_file, + 'NETWORK_ID=%s' % str(network_ref['id']), + 'dnsmasq', + '--strict-order', + '--bind-interfaces', + '--conf-file=%s' % config_file, + '--pid-file=%s' % pid_path, + '--dhcp-optsfile=%s' % opts_path, + '--listen-address=%s' % network_ref['dhcp_server'], + '--except-interface=lo', + '--dhcp-range=set:%s,%s,static,%s,%ss' % + (network_ref['label'], + network_ref['dhcp_start'], + network_ref['netmask'], + dhcp_lease_time), + '--dhcp-lease-max=%s' % lease_max, + '--dhcp-hostsfile=%s' % conf_path, + '--dhcp-script=%s' % dhcp_bridge, + '--no-hosts', + '--leasefile-ro'] + + # dnsmasq currently gives an error for an empty domain, + # rather than ignoring. So only specify it if defined. + if dhcp_domain: + cmd.append('--domain=%s' % dhcp_domain) + + if dns_servers: + cmd.append('--no-resolv') + for dns_server in dns_servers: + cmd.append('--server=%s' % dns_server) + + if network_ref['multi_host']: + cmd.append('--addn-hosts=%s' % hosts_path) + + processutils.execute(*cmd) |