
"T`                 @   se   d  Z  d d l m Z d d g Z d g Z d Z d d   Z e d	 d	 d	 d
 d  Z d d   Z d	 S)a  
Spacewalk
---------
**Summary:** install and configure spacewalk

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/

**Internal name:** ``cc_spacewalk``

**Module frequency:** per instance

**Supported distros:** redhat, fedora

**Config keys**::

    spacewalk:
       server: <url>
       proxy: <proxy host>
       activation_key: <key>
    )subpZredhatZfedoraz	rhn-setupz'/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERTc              C   sj   d }  y# t  j  d d g d d d }  Wn: t  j k
 re } z | j d k rS   WYd  d  } ~ Xn X|  S)NFzrhn-profile-syncz	--verbosecaptureT   )r   ZProcessExecutionErrorZ	exit_code)Zalready_registerede r   ?/usr/lib/python3/dist-packages/cloudinit/config/cc_spacewalk.pyis_registered&   s    
r   Nc             C   s   | d  k	 r | j  d | |   d g } | j d d |  g  | j d t |  g  | rw | j d t |  g  | r | j d t |  g  | r | 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--activationkeyr   F)infoextendstrr   )serverZprofile_nameZca_cert_pathproxylogactivation_keycmdr   r   r   do_register4   s    	
	r   c          
   C   s   d | k r  | j  d |   d  S| d } | j d  } | r | j j t  t   s t | | j j d d  d | j d  d | d | j d  n | j  d	 |   d  S)
NZ	spacewalkz=Skipping module named %s, no 'spacewalk' key in configurationr   ZfqdnTr   r   r   zOSkipping module named %s, 'spacewalk/server' key was not found in configuration)	debuggetZdistroZinstall_packagesrequired_packagesr   r   Z
datasourceZget_hostname)nameZcfgZcloudr   Z_argsZspacewalk_serverr   r   r   handleG   s    	
		r   )	__doc__Z	cloudinitr   Zdistrosr   Zdef_ca_cert_pathr   r   r   r   r   r   r   <module>   s   	