o
    x[h  ã                   @   s\   d dl Z d dlZd dlZd dlmZmZ e  e¡ZdddœZ	dd„ Z
dd	d
„Zddd„ZdS )é    N)ÚhelpersÚutila'  
This system is using the EC2 Metadata Service, but does not appear to
be running on Amazon EC2 or one of cloud-init's known platforms that
provide a EC2 Metadata service. In the future, cloud-init may stop
reading metadata from the EC2 Metadata Service unless the platform can
be identified.

If you are seeing this message, please file a bug against
cloud-init at
   https://github.com/canonical/cloud-init/issues
Make sure to include the cloud provider your instance is
running on.

For more information see
  https://github.com/canonical/cloud-init/issues/2795

After you have filed a bug, you can disable this warning by
launching your instance with the cloud-config below, or
putting that content into
   /etc/cloud/cloud.cfg.d/99-ec2-datasource.cfg

#cloud-config
datasource:
 Ec2:
  strict_id: falseaã  
A new feature in cloud-init identified possible datasources for
this system as:
  {dslist}
However, the datasource used was: {source}

In the future, cloud-init will only attempt to use datasources that
are identified or specifically configured.
For more information see
  https://bugs.launchpad.net/bugs/1669675

If you are seeing this message, please file a bug against
cloud-init at
   https://github.com/canonical/cloud-init/issues
Make sure to include the cloud provider your instance is
running on.

After you have filed a bug, you can disable this warning by launching
your instance with the cloud-config below, or putting that content
into /etc/cloud/cloud.cfg.d/99-warnings.cfg

#cloud-config
warnings:
  dsid_missing_source: off)Ú
non_ec2_mdÚdsid_missing_sourcec                 C   s&   t j|  di ¡ di ¡d�}| d¡S )NÚsystem_infoÚpaths)Ú	path_cfgsÚwarnings)r   ÚPathsÚgetÚget_ipath_cur)Úcfgr   © r   ú4/usr/lib/python3/dist-packages/cloudinit/warnings.pyÚ_get_warn_dir?   s   ÿ
r   Tc                 C   s    ||f}| rt | tƒs|S t | d|f¡}|d u r|S |dv r!dS |dv r'dS | d¡\}}}|dkr5|S |rLz	t|ƒ}W d|fS  tyK   | Y S w d|fS )	Nr	   )ÚonÚtrueT©TN)ÚoffÚfalseF)FNú,ÚsleepT)Ú
isinstanceÚdictr   Úget_cfg_by_pathÚ	partitionÚintÚ
ValueError)r   ÚnameÚmoder   ÚdefaultÚncfgÚ_Úcsleepr   r   r   Ú_load_warn_cfgF   s*   
ýÿr$   c                 K   s  |d u ri }t || ||d�\}}|sd S t|  jd
i |¤Ž}d}|d }d| }d| d }	g }
| d¡ ¡ D ]	}|
 || ¡ q7|	}|rQd| }| |d¡d }t t	j
 t|ƒ| ¡|	d |
¡ d |	 ¡ t d|	d |
¡|¡ |r‚t d	|| ¡ t |¡ d S d S )N)r   r   éF   é   z
# %%-%ds #Ú*Ú
z  [sleeping for %d seconds]  z%s%s
%sz$sleeping %d seconds for warning '%s'r   )r$   ÚWARNINGSÚformatÚstripÚ
splitlinesÚappendÚcenterr   Ú
write_fileÚosÚpathÚjoinr   ÚLOGÚwarningÚdebugÚtimer   )r   r   r   r   ÚkwargsÚmsgÚmsgwidthÚ	linewidthÚfmtÚtoplineÚfmtlinesÚlineÚ	closelineÚsleepmsgr   r   r   Úshow_warningf   s4   þþrA   r   )NNT)Úloggingr0   r6   Ú	cloudinitr   r   Ú	getLoggerÚ__name__r3   r)   r   r$   rA   r   r   r   r   Ú<module>   s   
æ5
 