U 'Dg@sUdZddlZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZd d d d d dgZde gedgdZe ed<eeZee eeddddZdS)zPhone Home: Post data to urlN) templater url_helperutil)Cloud)Config) MetaSchema) ALL_DISTROS) PER_INSTANCE pub_key_rsa pub_key_ecdsapub_key_ed25519 instance_idhostnamefqdnZ cc_phone_home phone_home)idZdistrosZ frequencyZactivate_by_schema_keysmeta)namecfgcloudargsreturnc Cst|dkrt|d}n d|kr4td|dS|d}d|krTtd|dS|d}|dd}|d}z t|}Wn*tt fk rd }t td |YnX|dkrt }| | j|j d d jd }dddd} | D]@\} } zt| || <Wqtk r(t td| YqXqi} |D]2} | |krP|| | | <nd| | <td| q4i}| D]*\} }|dkrd|| <n t||| <qtd|di}t||}z$tj|||ddt|jdWn&tk rt td||YnXdS)Nrrz=Skipping module named %s, no 'phone_home' configuration foundurlzFSkipping module named %s, no 'url' found in 'phone_home' configurationZpostalltries z?Configuration entry 'tries' is not an integer, using %s insteadT)r)r rrz/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 availablezN/AZ INSTANCE_IDr )dataZretriesZ sec_betweenZ ssl_detailsz0Failed to post phone home data to %s in %s tries)lenrZ read_confLOGdebugZwarninggetint ValueError TypeErrorZlogexc POST_LIST_ALLZget_instance_idZ get_hostnameritemsZload_text_file ExceptionstrrZ render_stringrZread_file_or_urlZfetch_ssl_detailspaths)rrrrZph_cfgrZ post_listrZall_keysZpubkeysnpathZ submit_keyskZreal_submit_keysvZ url_paramsr/@/usr/lib/python3/dist-packages/cloudinit/config/cc_phone_home.pyhandle1s            r1)__doc__ZloggingZ cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.distrosrZcloudinit.settingsr r&r__annotations__Z getLogger__name__r r)listr1r/r/r/r0 s*