
    x[h              
           U d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ g d	Zd
egedgdZeed<    ej&                  e      Zdede	dededdf
dZy)zPhone Home: Post data to url    N)	templater
url_helperutil)Cloud)Config)
MetaSchema)ALL_DISTROS)PER_INSTANCE)pub_key_rsapub_key_ecdsapub_key_ed25519instance_idhostnamefqdncc_phone_home
phone_home)iddistros	frequencyactivate_by_schema_keysmetanamecfgcloudargsreturnc           	         |rt        j                  |d         }n d|vrt        j                  d|        y |d   }d|vrt        j	                  d|        y |d   }|j                  dd      }|j                  d      }	 t        |      }|dk(  rt        }|j                         |j                         j                  |j                  d      j                  d}dddd}	|	j                         D ]  \  }
}	 t        j                  |      ||
<     i }|D ]*  }||v r	||   ||<   d ||<   t        j	                  d|       , i }|j                         D ]  \  }}|d||<   t#        |      ||<    d|d   i}t%        j&                  ||      }	 t)        j*                  |||dz
  dt        j,                  |j.                               y # t        t        f$ r! d	}t        j                  t        d
|       Y qw xY w# t         $ r t        j                  t        d|       Y 5w xY w# t         $ r t        j                  t        d||       Y y w xY w)Nr   r   z=Skipping module named %s, no 'phone_home' configuration foundurlzFSkipping module named %s, no 'url' found in 'phone_home' configurationpostalltries
   z?Configuration entry 'tries' is not an integer, using %s insteadT)r   )r   r   r   z/etc/ssh/ssh_host_rsa_key.pubz/etc/ssh/ssh_host_ecdsa_key.pubz!/etc/ssh/ssh_host_ed25519_key.pub)r   r   r   z1%s: failed to open, can not phone home that data!z=Requested key %s from 'post' configuration list not availablezN/AINSTANCE_IDr         )dataretriessec_betweenssl_detailsz0Failed to post phone home data to %s in %s tries)r   	read_confLOGdebugwarninggetint
ValueError	TypeErrorlogexcPOST_LIST_ALLget_instance_idget_hostnamer   itemsload_text_file	Exceptionstrr   render_stringr   read_file_or_urlfetch_ssl_detailspaths)r   r   r   r   ph_cfgr   	post_listr!   all_keyspubkeysnpathsubmit_keyskreal_submit_keysv
url_paramss                    @/usr/lib/python3/dist-packages/cloudinit/config/cc_phone_home.pyhandlerJ   1   s   Q(s"II6
 \"F;	

 	
-C

65)IJJwE
E
 E!	 ,,.&&(11"""-66H 7:>G ==? 4	--d3HQK K 	=%a[KN!KNKK4	 !!# )19"'Q"%a&Q	) 	x.J 
!
!#z
2C
##!AI..u{{;	
s 	" 
M	

4  	KKH$	L  
CS%	

s6    G 9H :H+ ,G=<G= $H('H(+%II)__doc__logging	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.distrosr	   cloudinit.settingsr
   r3   r   __annotations__	getLogger__name__r+   r9   listrJ        rI   <module>rY      s    #  1 1 ! # . ) + } ,~	j  g!]
 ]
6 ]
% ]
t ]
 ]
rX   