3 \me @sUdZddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m Z mZddlmZdd lmZeZd d d d dddgZdZdddeegeededgdgdZe eeZejeZee e eddddZdS)zPhone Home: Post data to urlN)dedent) templater url_helperutil)Cloud)Config) MetaSchema get_meta_doc) ALL_DISTROS) PER_INSTANCE pub_key_dsa pub_key_rsa pub_key_ecdsapub_key_ed25519 instance_idhostnamefqdnajThis module can be used to post data to a remote host after boot is complete. If the post url contains the string ``$INSTANCE_ID`` it will be replaced with the id of the current instance. Either all data can be posted or a list of keys to post. Available keys are: - ``pub_key_dsa`` - ``pub_key_rsa`` - ``pub_key_ecdsa`` - ``pub_key_ed25519`` - ``instance_id`` - ``hostname`` - ``fdqn`` Data is sent as ``x-www-form-urlencoded`` arguments. **Example HTTP POST**: .. code-block:: http POST / HTTP/1.1 Content-Length: 1337 User-Agent: Cloud-Init/21.4 Accept-Encoding: gzip, deflate Accept: */* Content-Type: application/x-www-form-urlencoded pub_key_dsa=dsa_contents&pub_key_rsa=rsa_contents&pub_key_ecdsa=ecdsa_contents&pub_key_ed25519=ed25519_contents&instance_id=i-87018aed&hostname=myhost&fqdn=myhost.internal Z cc_phone_homez Phone HomezPost data to urlzt phone_home: url: http://example.com/$INSTANCE_ID/ post: all as phone_home: url: http://example.com/$INSTANCE_ID/ post: - pub_key_dsa - pub_key_rsa - pub_key_ecdsa - pub_key_ed25519 - instance_id - hostname - fqdn tries: 5 phone_home)idnametitle descriptionZdistros frequencyZexamplesZactivate_by_schema_keys)rcfgcloudargsreturncCst|dkrtj|d}n d|kr4tjd|dS|d}d|krTtjd|dS|d}|jdd}|jd}y t|}Wn*tt fk rd }tj td |YnX|dkrt }|j |j j|j d d jd }ddddd} xL| jD]@\} } ytj| || <Wqtk r,tj td| YqXqWi} x:|D]2} | |krX|| | | <nd| | <tjd| q s>