o
    x[ho  ã                
   @   sÌ   U d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ d	Zd
ZdZddgedgdœZeed< e e¡Zeeefdd„Zdedede
deddf
dd„ZdS )z5Mcollective: Install, configure and start mcollectiveé    N)Ú	ConfigObj)ÚsubpÚutil)ÚCloud)ÚConfig)Ú
MetaSchema)ÚPER_INSTANCEz&/etc/mcollective/ssl/server-public.pemz'/etc/mcollective/ssl/server-private.pemz/etc/mcollective/server.cfgÚcc_mcollectiveÚallÚmcollective)ÚidÚdistrosÚ	frequencyÚactivate_by_schema_keysÚmetac              
   C   sœ  zt j|dd�}tt |¡ƒ}W n" ty2 } z|jtjkr‚ t 	d|¡ tƒ }W Y d }~nd }~ww |  
¡ D ]\\}}|dkrPt j||dd� ||d< d|d	< q7|d
kret j||dd� ||d< d|d	< q7t|tƒro|||< q7t|tƒr�||jvr}i ||< | 
¡ D ]
\}	}
|
|| |	< q�q7t|ƒ||< q7z
t  |d| ¡ W n ty¸ } z|jtjkr­n‚ W Y d }~nd }~ww t ¡ }| |¡ t j|| ¡ dd� d S )NF)Úquietz4Did not find file %s (starting with an empty config)zpublic-certi¤  )Úmodezplugin.ssl_server_publicÚsslÚsecurityproviderzprivate-certi€  zplugin.ssl_server_privatez%s.old)r   Úload_binary_filer   ÚioÚBytesIOÚIOErrorÚerrnoÚENOENTÚLOGÚdebugÚitemsÚ
write_fileÚ
isinstanceÚstrÚdictÚsectionsÚcopyÚwriteÚgetvalue)ÚconfigÚ
server_cfgÚpubcert_fileÚpricert_fileÚold_contentsÚmcollective_configÚeÚcfg_nameÚcfgÚoÚvÚcontents© r2   úA/usr/lib/python3/dist-packages/cloudinit/config/cc_mcollective.pyÚ	configure(   sV   þ€ø	





ÿþ€ý
r4   Únamer.   ÚcloudÚargsÚreturnc                 C   sZ   d|vrt  d| ¡ d S |d }|j dg¡ d|v r"t|d d� tjg d¢dd� d S )Nr   z?Skipping module named %s, no 'mcollective' key in configurationÚconf)r&   )Úservicer   ÚrestartF)Úcapture)r   r   ÚdistroÚinstall_packagesr4   r   )r5   r.   r6   r7   Úmcollective_cfgr2   r2   r3   Úhandlee   s   þr@   )Ú__doc__r   r   ÚloggingÚ	configobjr   Ú	cloudinitr   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.settingsr   ÚPUBCERT_FILEÚPRICERT_FILEÚ
SERVER_CFGr   Ú__annotations__Ú	getLoggerÚ__name__r   r4   r    Úlistr@   r2   r2   r2   r3   Ú<module>   s0   	ü

ü"=