a '¡Dgÿã@s¤UdZddlZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZgd ¢Zd e ged gd œZe ed <e e¡Zee eeddœdd„ZdS)zPhone 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ÚfqdnZ cc_phone_homeÚ phone_home)ÚidZdistrosZ frequencyZactivate_by_schema_keysÚmeta)ÚnameÚcfgÚcloudÚargsÚreturnc Cst|ƒdkrt |d¡}n d|vr4t d|¡dS|d}d|vrTt d|¡dS|d}| dd¡}| d¡}z t|ƒ}Wn(tt fy¦d }t  td |¡Yn0|dkr´t }|  ¡|  ¡j|j d d jd œ}ddddœ} |  ¡D]>\} } zt | ¡|| <Wqèty$t  td| ¡Yqè0qèi} |D]2} | |vrL|| | | <nd| | <t d| ¡q0i}|  ¡D]*\} }|durŒd|| <n t|ƒ|| <qpd|di}t ||¡}z$tj|||ddt |j¡dWn$tyüt  td||¡Yn0dS)Nrrz=Skipping module named %s, no 'phone_home' configuration foundÚurlzFSkipping module named %s, no 'url' found in 'phone_home' configurationZpostÚallÚtriesé 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_confÚLOGÚdebugZwarningÚgetÚintÚ ValueErrorÚ TypeErrorZlogexcÚ POST_LIST_ALLZget_instance_idZ get_hostnamerÚitemsZload_text_fileÚ ExceptionÚstrrZ render_stringrZread_file_or_urlZfetch_ssl_detailsÚpaths)rrrrZph_cfgrZ post_listrZall_keysZpubkeysÚnÚpathZ submit_keysÚkZreal_submit_keysÚvZ url_params©r/úB/usr/lib/python3.9/site-packages/cloudinit/config/cc_phone_home.pyÚhandle1s’ ýý   ý  ýýÿ  ý  ÿ  û ÿr1)Ú__doc__ZloggingZ cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.distrosrZcloudinit.settingsr r&rÚ__annotations__Z getLoggerÚ__name__r r)Úlistr1r/r/r/r0Ú s      ü