forked from pool/cloud-init
5ee9623a83
- add the distro specific handler for openSUSE + patch openSUSEHandler.diff - fix syntax in SLE handler + dict access uses [] not {}, duh (forwarded request 179074 from rjschwei) OBS-URL: https://build.opensuse.org/request/show/179244 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cloud-init?expand=0&rev=3
91 lines
3.0 KiB
Diff
91 lines
3.0 KiB
Diff
diff -urN cloud-init-0.7.2/cloudinit/distros/opensuse.py cloud-init-0.7.2.os/cloudinit/distros/opensuse.py
|
|
--- cloud-init-0.7.2/cloudinit/distros/opensuse.py 1969-12-31 19:00:00.000000000 -0500
|
|
+++ cloud-init-0.7.2.os/cloudinit/distros/opensuse.py 2013-06-15 06:26:15.312348359 -0400
|
|
@@ -0,0 +1,86 @@
|
|
+# vi: ts=4 expandtab
|
|
+#
|
|
+# Copyright (C) 2013 SUSE LLC
|
|
+#
|
|
+# Author: Robert Schweikert <rjschwei@suse.com>
|
|
+#
|
|
+# Leaning very heavily on the RHEL implementation
|
|
+#
|
|
+# This program is free software: you can redistribute it and/or modify
|
|
+# it under the terms of the GNU General Public License version 3, as
|
|
+# published by the Free Software Foundation.
|
|
+#
|
|
+# This program is distributed in the hope that it will be useful,
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+# GNU General Public License for more details.
|
|
+#
|
|
+# You should have received a copy of the GNU General Public License
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+
|
|
+import os
|
|
+
|
|
+from cloudinit.distros import sles
|
|
+
|
|
+from cloudinit.distros.parsers.resolv_conf import ResolvConf
|
|
+from cloudinit.distros.parsers.sys_conf import SysConf
|
|
+
|
|
+from cloudinit import helpers
|
|
+from cloudinit import log as logging
|
|
+from cloudinit import util
|
|
+
|
|
+from cloudinit.settings import PER_INSTANCE
|
|
+
|
|
+LOG = logging.getLogger(__name__)
|
|
+
|
|
+class Distro(sles.Distro):
|
|
+ systemd_locale_conf_fn = '/etc/locale.conf'
|
|
+
|
|
+ def __init__(self, name, cfg, paths):
|
|
+ sles.Distro.__init__(self, name, cfg, paths)
|
|
+
|
|
+ def apply_locale(self, locale, out_fn=None):
|
|
+ if os.path.exists('/usr/bin/localectl'):
|
|
+ if not out_fn:
|
|
+ out_fn = systemd_locale_conf_fn
|
|
+ locale_cfg = {
|
|
+ 'LANG': locale,
|
|
+ }
|
|
+ else:
|
|
+ if not out_fn:
|
|
+ out_fn = self.locale_conf_fn
|
|
+ locale_cfg = {
|
|
+ 'RC_LANG': locale,
|
|
+ }
|
|
+ util.update_sysconfig_file(out_fn, locale_cfg)
|
|
+
|
|
+ def _write_hostname(self, hostname, out_fn):
|
|
+ if os.path.exists('/usr/bin/hostnamectl'):
|
|
+ util.subp(['hostnamectl', 'set-hostname', str(hostname)])
|
|
+ else:
|
|
+ host_cfg = {
|
|
+ 'HOSTNAME': hostname,
|
|
+ }
|
|
+ util.update_sysconfig_file(out_fn, host_cfg)
|
|
+
|
|
+ def _select_hostname(self, hostname, fqdn):
|
|
+ if fqdn:
|
|
+ return fqdn
|
|
+ return hostname
|
|
+
|
|
+ def _read_system_hostname(self):
|
|
+ host_fn = self.hostname_conf_fn
|
|
+ return (host_fn, self._read_hostname(host_fn))
|
|
+
|
|
+ def _read_hostname(self, filename, default=None):
|
|
+ (out, _err) = util.subp(['hostname'])
|
|
+ if len(out):
|
|
+ return out
|
|
+ else:
|
|
+ (_exists, contents) = self._read_conf(filename)
|
|
+ if 'HOSTNAME' in contents:
|
|
+ return contents['HOSTNAME']
|
|
+ else:
|
|
+ return default
|
|
+
|
|
+
|