U
    g                     @   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!eeeeeee	j
 d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 kr6tjdddd}|| _d S )Nzunnamed-cloud-reporterF)nameZdescriptionZ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   ZfunctorargsZfreqZclear_on_failr   r   r   r   ;   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_filename>   s    
zCloud.get_template_filenameTc                 C   s   | j |S r   )r	   get_userdata)r   Zapply_filterr   r   r   r$   J   s    zCloud.get_userdatac                 C   s
   | j  S r   )r	   get_instance_idr   r   r   r   r%   M   s    zCloud.get_instance_idc                 C   s   | j jS r   )r	   launch_indexr   r   r   r   r&   P   s    zCloud.launch_indexc                 C   s
   | j  S r   )r	   get_public_ssh_keysr   r   r   r   r'   T   s    zCloud.get_public_ssh_keysc                 C   s
   | j  S r   )r	   
get_localer   r   r   r   r(   W   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+   Z   s     zCloud.get_hostnamec                 C   s   | j |S r   )r	   device_name_to_devicer   r   r   r   r   r,   _   s    zCloud.device_name_to_devicec                 C   s   | j |S r   )r
   get_ipath_curr-   r   r   r   r.   b   s    zCloud.get_ipath_curc                 C   s   | j |S r   )r
   	get_cpathr-   r   r   r   r/   e   s    zCloud.get_cpathc                 C   s   | j |S r   )r
   	get_ipathr-   r   r   r   r0   h   s    zCloud.get_ipath)N)NF)T)FF)N)N)N)__name__
__module____qualname__r   r   dictr   r   r   r   r   r   propertyr   r   r#   r$   r%   r&   r'   r(   r+   r,   r.   r/   r0   r   r   r   r   r      s0    






r   )r   Zloggingr   typingr   Zcloudinit.distrosr   Zcloudinit.helpersr   r   Zcloudinit.reportingr   Zcloudinit.sourcesr   Z	getLoggerr1   r    r   r   r   r   r   <module>   s   
