3 \me @ s U d Z ddlZddlmZ ddlmZmZmZ ddlm Z ddl mZ ddlm Z mZ ddlmZ dd lmZ eZd ddd dddgZdZdddeegeededgdgdZe eeZ ejeZeee eddddZdS )zPhone Home: Post data to url N)dedent) templater url_helperutil)Cloud)Config) MetaSchemaget_meta_doc)ALL_DISTROS)PER_INSTANCEpub_key_dsapub_key_rsa pub_key_ecdsapub_key_ed25519instance_idhostnamefqdnaj This 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)idnametitledescriptionZdistros frequencyZexamplesZactivate_by_schema_keys)r cfgcloudargsreturnc C s t |dkrtj|d }n d|kr4tjd| d S |d }d|krTtjd| d S |d }|jdd}|jd}yt|}W n* tt fk r d }tj td | Y nX |dkrt}|j |j j|j ddjd }ddddd} xL| j D ]@\} }ytj||| <