HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_phone_home.cpython-310.pyc
o

�Ad�@s�UdZddlmZddlmZddlmZmZmZddl	m
Z
ddlmZddl
mZmZddlmZdd	lmZeZgd
�ZdZdd
deegeed�ed�gdgd�Zeed<ee�Zdedede
dededdf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
�
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�title�description�distros�	frequency�examples�activate_by_schema_keys�metar�cfg�cloud�log�args�returnNc	Cs�t|�dkrt�|d�}nd|vr|�d|�dS|d}d|vr*|�d|�dS|d}|�dd�}|�d�}zt|�}WnttfySd	}t�	|d
|�Ynw|dkrZt
}|��|��j
|jdd�j
d
�}	ddddd�}
|
��D]\}}z	t�|�|	|<Wquty�t�	|d|�Yquwi}
|D]}||	vr�|	||
|<q�d|
|<|�d|�q�i}|
��D]\}}|dur�d||<q�t|�||<q�d|	di}t�||�}ztj|||ddt�|j�d�WdSty�t�	|d||�YdSw)Nrrz=Skipping module named %s, no 'phone_home' configuration found�urlzFSkipping module named %s, no 'url' found in 'phone_home' configuration�post�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/A�INSTANCE_IDr��)�data�retries�sec_between�ssl_detailsz0Failed to post phone home data to %s in %s tries)�lenr�	read_conf�debug�warning�get�int�
ValueError�	TypeError�logexc�
POST_LIST_ALL�get_instance_id�get_hostnamer�items�	load_file�	Exception�strr�
render_stringr�read_file_or_url�fetch_ssl_details�paths)rrr r!r"�ph_cfgr$�	post_listr'�all_keys�pubkeys�n�path�submit_keys�k�real_submit_keys�v�
url_params�rO�@/usr/lib/python3/dist-packages/cloudinit/config/cc_phone_home.py�handleos���
�������
�
�
��rQ)�__doc__�loggingr�textwrapr�	cloudinitrrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	r
�cloudinit.distrosr�cloudinit.settingsrrr9�MODULE_DESCRIPTIONr�__annotations__r?�listrQrOrOrOrP�<module>sR
����"������