o
    m[hà  ã                   @   st   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ e e¡ZG dd„ dƒZdS )	é    N)ÚOptional)ÚDistro)ÚPathsÚRunners)Úevents)Ú
DataSourcec                   @   s´   e Zd Z	d&dedededededee	j
 f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 )*ÚCloudNÚ
datasourceÚpathsÚcfgÚdistroÚrunnersÚreporterc                 C   s@   || _ || _|| _|| _|| _|d u rtjdddd�}|| _d S )Nzunnamed-cloud-reporterF)ÚnameÚdescriptionÚreporting_enabled)r	   r
   r   Ú_cfgÚ_runnersr   ÚReportEventStackr   )Úselfr	   r
   r   r   r   r   © r   ú1/usr/lib/python3/dist-packages/cloudinit/cloud.pyÚ__init__    s   	ý
zCloud.__init__c                 C   s   t  | j¡S ©N)ÚcopyÚdeepcopyr   ©r   r   r   r   r   6   s   z	Cloud.cfgFc                 C   s   | j  |||||¡S r   )r   Úrun)r   r   ÚfunctorÚargsÚfreqÚclear_on_failr   r   r   r   ;   s   z	Cloud.runc                 C   s6   | j j| }tj |¡st dtj |¡|¡ d S |S )Nz-No template found in %s for template named %s)r
   Útemplate_tplÚosÚpathÚisfileÚLOGÚwarningÚdirname)r   r   Úfnr   r   r   Úget_template_filename>   s   
ýzCloud.get_template_filenameTc                 C   ó   | j  |¡S r   )r	   Úget_userdata)r   Úapply_filterr   r   r   r,   J   ó   zCloud.get_userdatac                 C   ó
   | j  ¡ S r   )r	   Úget_instance_idr   r   r   r   r0   M   ó   
zCloud.get_instance_idc                 C   s   | j jS r   )r	   Úlaunch_indexr   r   r   r   r2   P   s   zCloud.launch_indexc                 C   r/   r   )r	   Úget_public_ssh_keysr   r   r   r   r3   T   r1   zCloud.get_public_ssh_keysc                 C   r/   r   )r	   Ú
get_localer   r   r   r   r4   W   r1   zCloud.get_localec                 C   s   | j j||d�S )N)ÚfqdnÚmetadata_only)r	   Úget_hostname)r   r5   r6   r   r   r   r7   Z   s   ÿzCloud.get_hostnamec                 C   r+   r   )r	   Údevice_name_to_device©r   r   r   r   r   r8   _   r.   zCloud.device_name_to_devicec                 C   r+   r   )r
   Úget_ipath_curr9   r   r   r   r:   b   r.   zCloud.get_ipath_curc                 C   r+   r   )r
   Ú	get_cpathr9   r   r   r   r;   e   r.   zCloud.get_cpathc                 C   r+   r   )r
   Ú	get_ipathr9   r   r   r   r<   h   r.   zCloud.get_ipathr   )NF)T)FF)Ú__name__Ú
__module__Ú__qualname__r   r   Údictr   r   r   r   r   r   Úpropertyr   r   r*   r,   r0   r2   r3   r4   r7   r8   r:   r;   r<   r   r   r   r   r      s<    ùþýüûú
ù






r   )r   Úloggingr#   Útypingr   Úcloudinit.distrosr   Úcloudinit.helpersr   r   Úcloudinit.reportingr   Úcloudinit.sourcesr   Ú	getLoggerr=   r&   r   r   r   r   r   Ú<module>   s   
