U
    bÙ  ã                   @   sF   d dl Z d dlZd dlmZ d dlmZ e e¡Z	G dd„ de
ƒZdS )é    N)Úlog)Úeventsc                   @   sš   e Zd Zd"dd„Zdd„ Zedd„ ƒZd#d	d
„Zdd„ Zd$dd„Z	dd„ Z
edd„ ƒZdd„ Zdd„ Zd%dd„Zdd„ Zd&dd„Zd'dd„Zd(d d!„ZdS ))ÚCloudNc                 C   s@   || _ || _|| _|| _|| _|d kr6tjdddd�}|| _d S )Nzunnamed-cloud-reporterF)ÚnameZdescriptionZreporting_enabled)Ú
datasourceÚpathsÚdistroÚ_cfgÚ_runnersr   ZReportEventStackÚreporter)Úselfr   r   Úcfgr   Zrunnersr   © r   ú1/usr/lib/python3/dist-packages/cloudinit/cloud.pyÚ__init__   s    ýzCloud.__init__c                 C   s   t  ¡  t  | j¡ d S ©N)ÚloggingZresetLoggingZsetupLoggingr   ©r   r   r   r   Úcycle_logging-   s    zCloud.cycle_loggingc                 C   s   t  | j¡S r   )ÚcopyÚdeepcopyr	   r   r   r   r   r   1   s    z	Cloud.cfgFc                 C   s   | j  |||||¡S r   )r
   Úrun)r   r   ZfunctorÚargsZfreqZclear_on_failr   r   r   r   6   s    z	Cloud.runc                 C   s6   | j j| }tj |¡s2t dtj |¡|¡ d S |S )Nz-No template found in %s for template named %s)r   Ztemplate_tplÚosÚpathÚisfileÚLOGZwarningÚdirname)r   r   Úfnr   r   r   Úget_template_filename9   s    
ýzCloud.get_template_filenameTc                 C   s   | j  |¡S r   )r   Úget_userdata)r   Zapply_filterr   r   r   r    E   s    zCloud.get_userdatac                 C   s
   | j  ¡ S r   )r   Úget_instance_idr   r   r   r   r!   H   s    zCloud.get_instance_idc                 C   s   | j jS r   )r   Úlaunch_indexr   r   r   r   r"   K   s    zCloud.launch_indexc                 C   s
   | j  ¡ S r   )r   Úget_public_ssh_keysr   r   r   r   r#   O   s    zCloud.get_public_ssh_keysc                 C   s
   | j  ¡ S r   )r   Ú
get_localer   r   r   r   r$   R   s    zCloud.get_localec                 C   s   | j j||d�S )N)ÚfqdnÚmetadata_only)r   Úget_hostname)r   r%   r&   r   r   r   r'   U   s     ÿzCloud.get_hostnamec                 C   s   | j  |¡S r   )r   Údevice_name_to_device©r   r   r   r   r   r(   Z   s    zCloud.device_name_to_devicec                 C   s   | j  |¡S r   )r   Úget_ipath_curr)   r   r   r   r*   ]   s    zCloud.get_ipath_curc                 C   s   | j  |¡S r   )r   Ú	get_cpathr)   r   r   r   r+   `   s    zCloud.get_cpathc                 C   s   | j  |¡S r   )r   Ú	get_ipathr)   r   r   r   r,   c   s    zCloud.get_ipath)N)NF)T)FF)N)N)N)Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr   r   r   r    r!   r"   r#   r$   r'   r(   r*   r+   r,   r   r   r   r   r      s"   







r   )r   r   Z	cloudinitr   r   Zcloudinit.reportingr   Z	getLoggerr-   r   Úobjectr   r   r   r   r   Ú<module>   s
   
