diff options
author | Gonéri Le Bouder <goneri@lebouder.net> | 2022-01-04 12:50:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 11:50:31 -0600 |
commit | d4bea4a44a0405aaf0d181d4bffff6c07d2fb5ba (patch) | |
tree | 8bfcc9acd9a94981e4db8c10573dccc6b80746dd /cloudinit/net | |
parent | a97fd062f7dbd4b824fd006edd08927ef9dbf24a (diff) | |
download | vyos-cloud-init-d4bea4a44a0405aaf0d181d4bffff6c07d2fb5ba.tar.gz vyos-cloud-init-d4bea4a44a0405aaf0d181d4bffff6c07d2fb5ba.zip |
openbsd: properly restart the network on 7.0 (#1150)
OpenBSD 7.0 comes with a new service called dhcpleased to manage the DHCP
requests.
Diffstat (limited to 'cloudinit/net')
-rw-r--r-- | cloudinit/net/openbsd.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cloudinit/net/openbsd.py b/cloudinit/net/openbsd.py index da50d2ba..70e9f461 100644 --- a/cloudinit/net/openbsd.py +++ b/cloudinit/net/openbsd.py @@ -1,5 +1,7 @@ # This file is part of cloud-init. See LICENSE file for license information. +import platform + import cloudinit.net.bsd from cloudinit import log as logging from cloudinit import subp, util @@ -30,13 +32,21 @@ class Renderer(cloudinit.net.bsd.BSDRenderer): util.write_file(fn, content) def start_services(self, run=False): + has_dhcpleasectl = bool(int(platform.release().split(".")[0]) > 6) if not self._postcmds: LOG.debug("openbsd generate postcmd disabled") return - subp.subp(["pkill", "dhclient"], capture=True, rcs=[0, 1]) - subp.subp(["route", "del", "default"], capture=True, rcs=[0, 1]) - subp.subp(["route", "flush", "default"], capture=True, rcs=[0, 1]) - subp.subp(["sh", "/etc/netstart"], capture=True) + if has_dhcpleasectl: # OpenBSD 7.0+ + subp.subp(["sh", "/etc/netstart"], capture=True) + for interface in self.dhcp_interfaces(): + subp.subp( + ["dhcpleasectl", "-w", "30", interface], capture=True + ) + else: + subp.subp(["pkill", "dhclient"], capture=True, rcs=[0, 1]) + subp.subp(["route", "del", "default"], capture=True, rcs=[0, 1]) + subp.subp(["route", "flush", "default"], capture=True, rcs=[0, 1]) + subp.subp(["sh", "/etc/netstart"], capture=True) def set_route(self, network, netmask, gateway): if network == "0.0.0.0": |