handler looks fine, comments in line. missing: doc/examples/cloud-config-spacewalk.txt
Diff comments: > diff --git a/cloudinit/config/cc_spacewalk.py > b/cloudinit/config/cc_spacewalk.py > new file mode 100644 > index 0000000..d82cfbf > --- /dev/null > +++ b/cloudinit/config/cc_spacewalk.py > @@ -0,0 +1,67 @@ > +# vi: ts=4 expandtab > +# > +# 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/>. > + > +""" > +**Summary:** helper to setup https://fedorahosted.org/spacewalk/ > + > +**Description:** This module will enable for configuring the needed > +actions to setup spacewalk on redhat based systems. > + > +It can be configured with the following option structure:: > + > + spacewalk: > + proxy: spacewalk api proxy (required) > + activation_key: spacewalk api activation key to use (required) > +""" > + > +from cloudinit import util > + > + > +distros = ['redhat', 'fedora'] > + > + > +def handle(name, cfg, cloud, log, _args): > + if 'spacewalk' not in cfg: > + log.debug(("Skipping module named %s," > + " no 'spacewalk' key in configuration"), name) > + return > + cfg = cfg['spacewalk'] > + spacewalk_proxy = cfg.get('proxy') > + spacewalk_activation_key = cfg.get('activation_key') > + if spacewalk_proxy and spacewalk_activation_key: > + distro = cloud.distro > + # Need to have this installed before further things will work. > + distro.install_packages(['rhn-setup']) We don't have one yet, but I'd really like to see a .is_package_installed() filter in the install_packages() check. The cost of yum and apt are much higher than dpkg-query or rpm -qi , or equiv database check. > + # Check to see if already registered and don't bother; this is > + # apparently done by trying to sync and if that fails then we > + # assume we aren't registered; which is sorta ghetto... > + already_registered = False > + try: > + util.subp(['rhn-profile-sync', '--verbose'], capture=False) > + already_registered = True > + except util.ProcessExecutionError as e: > + if e.exit_code != 1: > + raise > + if not already_registered: > + util.subp([ > + 'rhnreg_ks', > + '--serverUrl=https://%s/XMLRPC' % spacewalk_proxy, > + '--sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT', > + '--activationkey=%s' % spacewalk_activation_key, > + '--profilename=%s' % > cloud.datasource.get_hostname(fqdn=True), > + ], capture=False) > + else: > + log.debug(("Skipping module named %s," > + " 'spacewalk/proxy' or 'spacewalk/activation_key' key(s)" > + " were not found in configured data"), name) -- https://code.launchpad.net/~harlowja/cloud-init/+git/cloud-init/+merge/301224 Your team cloud init development team is requested to review the proposed merge of ~harlowja/cloud-init:spacewalk into cloud-init:master. _______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp