summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorGonéri Le Bouder <goneri@lebouder.net>2020-03-26 16:07:51 -0400
committerGitHub <noreply@github.com>2020-03-26 16:07:51 -0400
commit44039629e539ed48298703028ac8f10ad3c60d6e (patch)
treec806fe54818f44148e6e37bf02cac1ea1e868610 /cloudinit/distros
parent4c88d9341e75a1a14ba2e8bd0ab309e265229f7e (diff)
downloadvyos-cloud-init-44039629e539ed48298703028ac8f10ad3c60d6e.tar.gz
vyos-cloud-init-44039629e539ed48298703028ac8f10ad3c60d6e.zip
add Openbsd support (#147)
- tested on OpenBSD 6.6 - tested on OpenStack without config drive, and NoCloud with ISO config drive
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/bsd.py6
-rw-r--r--cloudinit/distros/netbsd.py13
-rw-r--r--cloudinit/distros/openbsd.py47
3 files changed, 64 insertions, 2 deletions
diff --git a/cloudinit/distros/bsd.py b/cloudinit/distros/bsd.py
index c58f897c..efc73d5d 100644
--- a/cloudinit/distros/bsd.py
+++ b/cloudinit/distros/bsd.py
@@ -114,3 +114,9 @@ class BSD(distros.Distro):
def set_timezone(self, tz):
distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
+
+ def apply_locale(self, locale, out_fn=None):
+ LOG.debug('Cannot set the locale.')
+
+ def apply_network_config_names(self, netconfig):
+ LOG.debug('Cannot rename network interface.')
diff --git a/cloudinit/distros/netbsd.py b/cloudinit/distros/netbsd.py
index 96794d76..69d07846 100644
--- a/cloudinit/distros/netbsd.py
+++ b/cloudinit/distros/netbsd.py
@@ -13,7 +13,13 @@ from cloudinit import util
LOG = logging.getLogger(__name__)
-class Distro(cloudinit.distros.bsd.BSD):
+class NetBSD(cloudinit.distros.bsd.BSD):
+ """
+ Distro subclass for NetBSD.
+
+ (N.B. OpenBSD inherits from this class.)
+ """
+
ci_sudoers_fn = '/usr/pkg/etc/sudoers.d/90-cloud-init-users'
group_add_cmd_prefix = ["groupadd"]
@@ -115,7 +121,7 @@ class Distro(cloudinit.distros.bsd.BSD):
LOG.debug('NetBSD cannot rename network interface.')
def _get_pkg_cmd_environ(self):
- """Return environment vars used in *BSD package_command operations"""
+ """Return env vars used in NetBSD package_command operations"""
os_release = platform.release()
os_arch = platform.machine()
e = os.environ.copy()
@@ -128,4 +134,7 @@ class Distro(cloudinit.distros.bsd.BSD):
pass
+class Distro(NetBSD):
+ pass
+
# vi: ts=4 expandtab
diff --git a/cloudinit/distros/openbsd.py b/cloudinit/distros/openbsd.py
new file mode 100644
index 00000000..dbe1f069
--- /dev/null
+++ b/cloudinit/distros/openbsd.py
@@ -0,0 +1,47 @@
+# Copyright (C) 2019-2020 Gonéri Le Bouder
+#
+# This file is part of cloud-init. See LICENSE file for license information.
+
+import os
+import platform
+
+import cloudinit.distros.netbsd
+from cloudinit import log as logging
+from cloudinit import util
+
+LOG = logging.getLogger(__name__)
+
+
+class Distro(cloudinit.distros.netbsd.NetBSD):
+ hostname_conf_fn = '/etc/myname'
+
+ def _read_hostname(self, filename, default=None):
+ return util.load_file(self.hostname_conf_fn)
+
+ def _write_hostname(self, hostname, filename):
+ content = hostname + '\n'
+ util.write_file(self.hostname_conf_fn, content)
+
+ def _get_add_member_to_group_cmd(self, member_name, group_name):
+ return ['usermod', '-G', group_name, member_name]
+
+ def lock_passwd(self, name):
+ try:
+ util.subp(['usermod', '-p', '*', name])
+ except Exception:
+ util.logexc(LOG, "Failed to lock user %s", name)
+ raise
+
+ def _get_pkg_cmd_environ(self):
+ """Return env vars used in OpenBSD package_command operations"""
+ os_release = platform.release()
+ os_arch = platform.machine()
+ e = os.environ.copy()
+ e['PKG_PATH'] = (
+ 'ftp://ftp.openbsd.org/pub/OpenBSD/{os_release}/'
+ 'packages/{os_arch}/').format(
+ os_arch=os_arch, os_release=os_release)
+ return e
+
+
+# vi: ts=4 expandtab