File openSUSEHandler.diff of Package cloud-init

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
+
+
openSUSE Build Service is sponsored by