diff --git a/cloud-init.changes b/cloud-init.changes index e63aafa..23c08bd 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Tue Jun 18 21:28:58 UTC 2013 - rschweikert@suse.com + +- integrate changes from HP + + update the sles handler, do not modify the util code integrate + routines directky into the sles handler + ~ add patch slesHandler.patch + ~ remove patch openSUSEHandler.diff + + add python dependencies + ~ python-argparse + ~ python-configobj + ~ python-oauth + + update the cloud-init config file + ------------------------------------------------------------------- Sat Jun 15 10:40:42 UTC 2013 - rschweikert@suse.com diff --git a/cloud-init.spec b/cloud-init.spec index 27e7c78..0abaf7c 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -28,10 +28,13 @@ Url: http://launchpad.net/cloud-init/ Source0: %{component}-%{version}.tar.bz2 Source1: cloud.cfg.suse Patch0: fixupSysVinit.patch -Patch1: slesHandler.diff +Patch1: slesHandler.patch Patch2: openSUSEHandler.diff +Requires: python-argparse Requires: python-boto Requires: python-cheetah +Requires: python-configobj +Requires: python-oauth Requires: python-prettytable Requires: python-requests Requires: python-xml @@ -107,6 +110,14 @@ mkdir -p %{buildroot}%{_localstatedir}/lib/cloud mkdir -p %{buildroot}%{_defaultdocdir} mv %{buildroot}/usr/share/doc/%{component} %{buildroot}%{docdir} cp -a %{S:1} %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg +%if 0%{?suse_version} +%if 0%{?sles_version} != 0 +sed -i s/INSERT_SUSE_DISTRO/sles/ %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg +%endif +%if 0%{?sles_version} == 0 +sed -i s/INSERT_SUSE_DISTRO/opensuse/ %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg +%endif +%endif # remove debian/ubuntu specific profile.d file (bnc#779553) rm -f %{buildroot}%{_sysconfdir}/profile.d/Z99-cloud-locale-test.sh diff --git a/cloud.cfg.suse b/cloud.cfg.suse index a38973e..44a7928 100644 --- a/cloud.cfg.suse +++ b/cloud.cfg.suse @@ -1,26 +1,35 @@ -# adapted default config for (open)SUSE systems -user: root -disable_root: False -preserve_hostname: False -cc_ready_cmd: [ /bin/true ] -syslog_fix_perms: root:root -# datasource_list: ["NoCloud", "ConfigDrive", "OVF", "MAAS", "Ec2", "CloudStack"] +# Adapted default config for (open)SUSE systems +users: + - root + +disable_root: false +preserve_hostname: false +syslog_fix_perms: root:root +mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] +ssh_genkeytypes: ['rsa', 'dsa'] + +# The modules that run in the 'init' stage cloud_init_modules: + - migrator - bootcmd + - write-files + - resizefs - set_hostname - update_hostname - update_etc_hosts - ca-certs - rsyslog + - users-groups - ssh +# The modules that run in the 'config' stage cloud_config_modules: - mounts - ssh-import-id - locale - set-passwords - - landscape + - package-update-upgrade-install - timezone - puppet - chef @@ -28,12 +37,25 @@ cloud_config_modules: - mcollective - disable-ec2-metadata - runcmd + - byobu +# The modules that run in the 'final' stage cloud_final_modules: - rightscale_userdata - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user + - ssh-authkey-fingerprints - keys-to-console + - phone-home - final-message + - power-state-change + +# System and/or distro specific settings +system_info: + distro: INSERT_SUSE_DISTRO + paths: + cloud_dir: /var/lib/cloud/ + templates_dir: /etc/cloud/templates/ + ssh_svcname: sshd diff --git a/slesHandler.diff b/slesHandler.patch similarity index 64% rename from slesHandler.diff rename to slesHandler.patch index 863c9f1..02354be 100644 --- a/slesHandler.diff +++ b/slesHandler.patch @@ -1,7 +1,21 @@ -diff -urN cloud-init-0.7.2.orig/cloudinit/config/cc_resolv_conf.py cloud-init-0.7.2/cloudinit/config/cc_resolv_conf.py ---- cloud-init-0.7.2.orig/cloudinit/config/cc_resolv_conf.py 2013-05-15 16:48:22.000000000 -0400 -+++ cloud-init-0.7.2/cloudinit/config/cc_resolv_conf.py 2013-06-13 19:13:57.269300572 -0400 -@@ -53,7 +53,7 @@ +Index: cloud-init-0.7.2/cloudinit/config/cc_resolv_conf.py +=================================================================== +--- cloud-init-0.7.2.orig/cloudinit/config/cc_resolv_conf.py 2013-06-18 15:11:17.016476944 +0200 ++++ cloud-init-0.7.2/cloudinit/config/cc_resolv_conf.py 2013-06-18 15:11:55.760669066 +0200 +@@ -1,8 +1,12 @@ + # vi: ts=4 expandtab + # + # Copyright (C) 2013 Craig Tracey ++# Copyright (C) 2013 SUSE LLC ++# Copyright (C) 2013 Hewlett-Packard Development Company, L.P. + # + # Author: Craig Tracey ++# Author: Robert Schweikert ++# Author: Juerg Haefliger + # + # 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 +@@ -53,7 +57,7 @@ frequency = PER_INSTANCE @@ -10,30 +24,102 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/config/cc_resolv_conf.py cloud-init-0. def generate_resolv_conf(cloud, log, params): -diff -urN cloud-init-0.7.2.orig/cloudinit/distros/__init__.py cloud-init-0.7.2/cloudinit/distros/__init__.py ---- cloud-init-0.7.2.orig/cloudinit/distros/__init__.py 2013-05-15 16:48:22.000000000 -0400 -+++ cloud-init-0.7.2/cloudinit/distros/__init__.py 2013-06-13 19:23:03.874975271 -0400 -@@ -38,7 +38,8 @@ +Index: cloud-init-0.7.2/cloudinit/distros/__init__.py +=================================================================== +--- cloud-init-0.7.2.orig/cloudinit/distros/__init__.py 2013-06-18 15:11:16.996476840 +0200 ++++ cloud-init-0.7.2/cloudinit/distros/__init__.py 2013-06-18 15:12:18.848783546 +0200 +@@ -1,13 +1,15 @@ + # vi: ts=4 expandtab + # + # Copyright (C) 2012 Canonical Ltd. +-# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. ++# Copyright (C) 2012, 2013 Hewlett-Packard Development Company, L.P. + # Copyright (C) 2012 Yahoo! Inc. ++# Copyright (C) 2013 SUSE LLC + # + # Author: Scott Moser + # Author: Juerg Haefliger + # Author: Joshua Harlow + # Author: Ben Howard ++# Author: Robert Schweikert + # + # 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 +@@ -38,7 +40,8 @@ OSFAMILIES = { 'debian': ['debian', 'ubuntu'], - 'redhat': ['fedora', 'rhel'] + 'redhat': ['fedora', 'rhel'], -+ 'suse' : ['opensuse', 'sles'] ++ 'suse': ['opensuse', 'sles'] } LOG = logging.getLogger(__name__) -diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloudinit/distros/sles.py ---- cloud-init-0.7.2.orig/cloudinit/distros/sles.py 1969-12-31 19:00:00.000000000 -0500 -+++ cloud-init-0.7.2/cloudinit/distros/sles.py 2013-06-13 19:00:56.837634255 -0400 -@@ -0,0 +1,212 @@ +@@ -347,7 +350,8 @@ + try: + util.subp(adduser_cmd, logstring=x_adduser_cmd) + except Exception as e: +- util.logexc(LOG, "Failed to create user %s due to error.", e) ++ util.logexc(LOG, "Failed to create user %s due to error.", ++ name) + raise e + + # Set password if plain-text password provided +@@ -358,10 +362,10 @@ + # lock account unless lock_password is False. + if kwargs.get('lock_passwd', True): + try: +- util.subp(['passwd', '--lock', name]) ++ util.subp(['passwd', '-l', name]) + except Exception as e: +- util.logexc(LOG, ("Failed to disable password logins for" +- "user %s" % name), e) ++ util.logexc(LOG, "Failed to disable password logins for " ++ "user %s", name) + raise e + + # Configure sudo access +@@ -385,7 +389,7 @@ + try: + util.subp(cmd, pass_string, logstring="chpasswd for %s" % user) + except Exception as e: +- util.logexc(LOG, "Failed to set password for %s" % user) ++ util.logexc(LOG, "Failed to set password for %s", user) + raise e + + return True +@@ -427,7 +431,7 @@ + util.append_file(sudo_base, sudoers_contents) + LOG.debug("Added '#includedir %s' to %s" % (path, sudo_base)) + except IOError as e: +- util.logexc(LOG, "Failed to write %s" % sudo_base, e) ++ util.logexc(LOG, "Failed to write %s", sudo_base) + raise e + util.ensure_dir(path, 0750) + +@@ -479,7 +483,7 @@ + util.subp(group_add_cmd) + LOG.info("Created new group %s" % name) + except Exception as e: +- util.logexc("Failed to create group %s" % name, e) ++ util.logexc("Failed to create group %s", name) + + # Add members to the group, if so defined + if len(members) > 0: +Index: cloud-init-0.7.2/cloudinit/distros/sles.py +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ cloud-init-0.7.2/cloudinit/distros/sles.py 2013-06-18 15:11:55.764669081 +0200 +@@ -0,0 +1,340 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2013 SUSE LLC ++# Copyright (C) 2013 Hewlett-Packard Development Company, L.P. +# +# Author: Robert Schweikert ++# Author: Juerg Haefliger +# -+# Leaning very heavily on the RHEL implementation ++# Leaning very heavily on the RHEL and Debian 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 @@ -51,6 +137,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + +from cloudinit import distros + ++from cloudinit.distros.parsers.hostname import HostnameConf +from cloudinit.distros.parsers.resolv_conf import ResolvConf +from cloudinit.distros.parsers.sys_conf import SysConf + @@ -62,6 +149,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + +LOG = logging.getLogger(__name__) + ++ +class Distro(distros.Distro): + clock_conf_fn = '/etc/sysconfig/clock' + locale_conf_fn = '/etc/sysconfig/language' @@ -81,7 +169,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + self.osfamily = 'suse' + + def install_packages(self, pkglist): -+ self.package_command('install', args='-l', pkgs=pkglist) ++ self.package_command('install', args='-l', pkgs=pkglist) + + def _adjust_resolve(self, dns_servers, search_servers): + try: @@ -109,7 +197,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + + def _write_network(self, settings): + # Convert debian settings to ifcfg format -+ entries = util.translate_network(settings) ++ entries = translate_network(settings) + LOG.debug("Translated ubuntu style network settings %s into %s", + settings, entries) + # Make the intermediate format as the suse format... @@ -138,7 +226,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + net_cfg['ETHTOOL_OPTIONS'] = '' + else: + net_cfg['FIREWALL'] = 'no' -+ util.update_sysconfig_file(net_fn, net_cfg, True) ++ self._update_sysconfig_file(net_fn, net_cfg, True) + if 'dns-nameservers' in info: + nameservers.extend(info['dns-nameservers']) + if 'dns-search' in info: @@ -147,35 +235,26 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + self._adjust_resolve(nameservers, searchservers) + return dev_names + -+ def apply_locale(self, locale, out_fn=None): -+ 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): -+ 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): -+ (_exists, contents) = self._read_conf(filename) -+ if 'HOSTNAME' in contents: -+ return contents['HOSTNAME'] -+ else: -+ return default ++ def _update_sysconfig_file(self, fn, adjustments, allow_empty=False): ++ if not adjustments: ++ return ++ (exists, contents) = self._read_conf(fn) ++ updated_am = 0 ++ for (k, v) in adjustments.items(): ++ if v is None: ++ continue ++ v = str(v) ++ if len(v) == 0 and not allow_empty: ++ continue ++ contents[k] = v ++ updated_am += 1 ++ if updated_am: ++ lines = [ ++ str(contents), ++ ] ++ if not exists: ++ lines.insert(0, util.make_header()) ++ util.write_file(fn, "\n".join(lines) + "\n", 0644) + + def _read_conf(self, fn): + exists = False @@ -187,6 +266,54 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + return (exists, + SysConf(contents)) + ++ def apply_locale(self, locale, out_fn=None): ++ if not out_fn: ++ out_fn = self.locale_conf_fn ++ locale_cfg = { ++ 'RC_LANG': locale, ++ } ++ self._update_sysconfig_file(out_fn, locale_cfg) ++ ++ def _select_hostname(self, hostname, fqdn): ++ # Prefer the short hostname over the long ++ # fully qualified domain name ++ if not hostname: ++ return fqdn ++ return hostname ++ ++ def _write_hostname(self, hostname, out_fn): ++ conf = None ++ try: ++ # Try to update the previous one ++ # so lets see if we can read it first. ++ conf = self._read_hostname_conf(out_fn) ++ except IOError: ++ pass ++ if not conf: ++ conf = HostnameConf('') ++ conf.set_hostname(hostname) ++ util.write_file(out_fn, str(conf), 0644) ++ ++ def _read_system_hostname(self): ++ host_fn = self.hostname_conf_fn ++ return (host_fn, self._read_hostname(host_fn)) ++ ++ def _read_hostname_conf(self, filename): ++ conf = HostnameConf(util.load_file(filename)) ++ conf.parse() ++ return conf ++ ++ def _read_hostname(self, filename, default=None): ++ hostname = None ++ try: ++ conf = self._read_hostname_conf(filename) ++ hostname = conf.hostname ++ except IOError: ++ pass ++ if not hostname: ++ return default ++ return hostname ++ + def _bring_up_interfaces(self, device_names): + if device_names and 'all' in device_names: + raise RuntimeError(('Distro %s can not translate ' @@ -204,7 +331,7 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + clock_cfg = { + 'TIMEZONE': str(tz), + } -+ util.update_sysconfig_file(self.clock_conf_fn, clock_cfg) ++ self._update_sysconfig_file(self.clock_conf_fn, clock_cfg) + # This ensures that the correct tz will be used for the system + util.copy(tz_file, self.tz_local_fn) + @@ -239,14 +366,6 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/distros/sles.py cloud-init-0.7.2/cloud + ['refresh'], freq=PER_INSTANCE) + + -diff -urN cloud-init-0.7.2.orig/cloudinit/util.py cloud-init-0.7.2/cloudinit/util.py ---- cloud-init-0.7.2.orig/cloudinit/util.py 2013-05-15 16:48:22.000000000 -0400 -+++ cloud-init-0.7.2/cloudinit/util.py 2013-06-13 19:27:57.877749273 -0400 -@@ -1744,3 +1744,110 @@ - mountinfo_path = '/proc/%s/mountinfo' % os.getpid() - lines = load_file(mountinfo_path).splitlines() - return parse_mount_info(path, lines, log) -+ +def translate_network(settings): + # Translate Debian based distro interface blobs as given in + # /etc/network/interfaces to an equivalent format for distributions @@ -332,31 +451,11 @@ diff -urN cloud-init-0.7.2.orig/cloudinit/util.py cloud-init-0.7.2/cloudinit/uti + if dev_name in real_ifaces: + real_ifaces[dev_name]['auto'] = True + return real_ifaces -+ -+def update_sysconfig_file(self, fn, adjustments, allow_empty=False): -+ if not adjustments: -+ return -+ (exists, contents) = self._read_conf(fn) -+ updated_am = 0 -+ for (k, v) in adjustments.items(): -+ if v is None: -+ continue -+ v = str(v) -+ if len(v) == 0 and not allow_empty: -+ continue -+ contents[k] = v -+ updated_am += 1 -+ if updated_am: -+ lines = [ -+ str(contents), -+ ] -+ if not exists: -+ lines.insert(0, make_header()) -+ write_file(fn, "\n".join(lines) + "\n", 0644) -diff -urN cloud-init-0.7.2.orig/templates/hosts.suse.tmpl cloud-init-0.7.2/templates/hosts.suse.tmpl ---- cloud-init-0.7.2.orig/templates/hosts.suse.tmpl 1969-12-31 19:00:00.000000000 -0500 -+++ cloud-init-0.7.2/templates/hosts.suse.tmpl 2013-06-13 19:26:00.120234961 -0400 -@@ -0,0 +1,25 @@ +Index: cloud-init-0.7.2/templates/hosts.suse.tmpl +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ cloud-init-0.7.2/templates/hosts.suse.tmpl 2013-06-18 15:11:55.764669081 +0200 +@@ -0,0 +1,24 @@ +#* + This file /etc/cloud/templates/hosts.suse.tmpl is only utilized + if enabled in cloud-config. Specifically, in order to enable it @@ -369,7 +468,7 @@ diff -urN cloud-init-0.7.2.orig/templates/hosts.suse.tmpl cloud-init-0.7.2/templ +# a.) make changes to the master file in /etc/cloud/templates/hosts.suse.tmpl +# b.) change or remove the value of 'manage_etc_hosts' in +# /etc/cloud/cloud.cfg or cloud-config from user-data -+# ++# +# The following lines are desirable for IPv4 capable hosts +127.0.0.1 localhost + @@ -381,4 +480,3 @@ diff -urN cloud-init-0.7.2.orig/templates/hosts.suse.tmpl cloud-init-0.7.2/templ +ff02::1 ipv6-allnodes +ff02::2 ipv6-allrouters +ff02::3 ipv6-allhosts -+