Your IP : 216.73.217.13


Current Path : /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_phone_home.cpython-38.pyc

U

�Ad�	@s�UdZddlmZddlmZddlmZmZmZddl	m
Z
ddlmZddl
mZmZddlmZdd	lmZeZd
ddd
dddgZdZdddeegeed�ed�gdgd�Zeed<ee�Zeee
eedd�dd�ZdS)zPhone Home: Post data to url�)�Logger)�dedent)�	templater�
url_helper�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�PER_INSTANCE�pub_key_dsa�pub_key_rsa�
pub_key_ecdsa�pub_key_ed25519�instance_id�hostname�fqdnajThis 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)�id�name�titleZdescriptionZdistros�	frequencyZexamplesZactivate_by_schema_keys�metaN)r�cfg�cloud�log�args�returnc	Cs
t|�dkrt�|d�}n d|kr4|�d|�dS|d}d|krT|�d|�dS|d}|�dd�}|�d�}zt|�}Wn*ttfk
r�d	}t�	|d
|�YnX|dkr�t
}|��|��j
|jdd�j
d
�}	ddddd�}
|
��D]@\}}zt�|�|	|<Wq�tk
�r*t�	|d|�Yq�Xq�i}
|D]2}||	k�rR|	||
|<nd|
|<|�d|��q6i}|
��D]*\}}|dk�r�d||<nt|�||<�qvd|	di}t�||�}z$tj|||ddt�|j�d�Wn&tk
�rt�	|d||�YnXdS)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)rrrz/etc/ssh/ssh_host_dsa_key.pubz/etc/ssh/ssh_host_rsa_key.pubz/etc/ssh/ssh_host_ecdsa_key.pubz!/etc/ssh/ssh_host_ed25519_key.pub)r
rrrz1%s: failed to open, can not phone home that data!z=Requested key %s from 'post' configuration list not availablezN/AZINSTANCE_IDr��)�dataZretriesZsec_betweenZssl_detailsz0Failed to post phone home data to %s in %s tries)�lenrZ	read_conf�debugZwarning�get�int�
ValueError�	TypeErrorZlogexc�
POST_LIST_ALLZget_instance_idZget_hostnamer�itemsZ	load_file�	Exception�strrZ
render_stringrZread_file_or_urlZfetch_ssl_details�paths)rrrrrZph_cfgrZ	post_listr!Zall_keysZpubkeys�n�pathZsubmit_keys�kZreal_submit_keys�vZ
url_params�r5�@/usr/lib/python3/dist-packages/cloudinit/config/cc_phone_home.py�handleos���
�
���
�

�
�
�r7)�__doc__Zloggingr�textwraprZ	cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemar	r
Zcloudinit.distrosrZcloudinit.settingsrrr,ZMODULE_DESCRIPTIONr�__annotations__r/�listr7r5r5r5r6�<module>	sR�
����"�