
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
\me              	   @   s   U d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ d	Zd
ddedddgeedgdgdZeeeZ ejeZddgZdgZdZdd ZeddfddZee	eeddddZdS )z*Spacewalk: Install and configure spacewalk    N)dedent)subp)Cloud)Config)
MetaSchemaget_meta_doc)PER_INSTANCEa  This module installs spacewalk and applies basic configuration. If the
``spacewalk`` config key is present spacewalk will be installed. The server to
connect to after installation must be provided in the ``server`` in spacewalk
configuration. A proxy to connect through and a activation key may optionally
be specified.

For more information about spacewalk see: https://fedorahosted.org/spacewalk/
Zcc_spacewalkZ	SpacewalkzInstall and configure spacewalkZrhelZfedoraZ	openeulerz            spacewalk:
              server: <url>
              proxy: <proxy host>
              activation_key: <key>
            	spacewalk)idnametitledescriptiondistrosZ	frequencyZexamplesZactivate_by_schema_keysZredhatz	rhn-setupz'/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERTc              C   sT   d} yt j ddgdd d} W n0 t jk
rN } z|jdkr> W Y d d }~X nX | S )NFzrhn-profile-syncz	--verbose)captureT   )r   ZProcessExecutionErrorZ	exit_code)Zalready_registerede r   "/usr/lib/python3.6/cc_spacewalk.pyis_registered4   s    
r   c             C   s   t jd||  dg}|jdd|  g |jdt|g |rN|jdt|g |rd|jdt|g |rz|jdt|g tj|d	d
 d S )Nz;Registering using `rhnreg_ks` profile '%s' into server '%s'Z	rhnreg_ksz--serverUrlzhttps://%s/XMLRPCz--profilenamez--proxyz--sslCACertz--activationkeyF)r   )LOGinfoextendstrr   )serverZprofile_nameZca_cert_pathproxyactivation_keycmdr   r   r   do_registerB   s    r   )r   cfgcloudargsreturnc             C   sz   d|krt jd|  d S |d }|jd}|rj|jjt t svt||jj	ddj
|jd|jdd nt jd	|  d S )
Nr	   z=Skipping module named %s, no 'spacewalk' key in configurationr   T)Zfqdnr   r   )r   r   zOSkipping module named %s, 'spacewalk/server' key was not found in configuration)r   debuggetZdistroZinstall_packagesrequired_packagesr   r   Z
datasourceZget_hostnameZhostname)r   r   r   r    Zspacewalk_serverr   r   r   handleZ   s$    
r%   )__doc__Zloggingtextwrapr   Z	cloudinitr   Zcloudinit.cloudr   Zcloudinit.configr   Zcloudinit.config.schemar   r   Zcloudinit.settingsr   ZMODULE_DESCRIPTIONmetaZ	getLogger__name__r   r   r$   Zdef_ca_cert_pathr   r   r   listr%   r   r   r   r   <module>   s6   

