
"T`P                 @   s   d  d l  m Z d  d l  m Z d  d l  m Z d  d l Z d  d l Z e j   Z d d d d i Z	 d	 d
   Z
 d d d d  Z d d d d d  Z d S)    )helpers)log)utilNZ
non_ec2_mda+  
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://bugs.launchpad.net/cloud-init/+filebug?field.tags=dsid
Make sure to include the cloud provider your instance is
running on.

For more information see
  https://bugs.launchpad.net/bugs/1660385

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: falseZdsid_missing_sourcea  
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://bugs.launchpad.net/cloud-init/+filebug?field.tags=dsid
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: offc             C   s7   t  j d |  j d i   j d i    } | j d  S)NZ	path_cfgsZsystem_infopathswarnings)r   PathsgetZget_ipath_cur)cfgr    r
   4/usr/lib/python3/dist-packages/cloudinit/warnings.py_get_warn_dirA   s    	!r   Tc             C   s   | | f } |  s# t  |  t  r' | St j |  d | f  } | d  k rO | S| d
 k r_ d S| d k ro d S| j d  \ } } } | d	 k r | S| r y t |  } Wn t k
 r | SYn Xd | f S)Nr   ontrueTofffalseF,sleep)r   ztrueT)TN)r   zfalseF)FN)
isinstancedictr   Zget_cfg_by_path	partitionint
ValueError)r	   namemoder   defaultZncfg_Zcsleepr
   r
   r   _load_warn_cfgG   s&    	r   c             K   s^  | d  k r i  } t  | |  d | d | \ } } | s= d  St |  j |   } d } | d } d | } d | d }	 g  }
 x. | j d  j   D] } |
 j | |  q W|	 } | r d | } | j | d  d } t j t	 j
 j t |  |   |	 d j |
  d |	  t j d	 |	 d j |
  |  | rZt j d
 | |   t j |  d  S)Nr   r   F      z
# %%-%ds #*
z  [sleeping for %d seconds]  z%s%s
%sz$sleeping %d seconds for warning '%s')r   WARNINGSformatstrip
splitlinesappendcenterr   Z
write_fileospathjoinr   LOGZwarningdebugtimer   )r   r	   r   r   kwargsmsgZmsgwidthZ	linewidthZfmtZtoplineZfmtlineslineZ	closelineZsleepmsgr
   r
   r   show_warningg   s0    !


r0   )Z	cloudinitr   r   Zloggingr   r'   r,   Z	getLoggerr*   r!   r   r   r0   r
   r
   r
   r   <module>   s   	 