%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/sources/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceExoscale.cpython-312.pyc

�

���f(#����ddlZddlmZmZmZmZmZmZddlm	Z	eje�ZdZ
dZdZdZdZd	ZGd
�dej&�Zeej*ej,ffgZd�Ze
eeeefd
�Ze
eeeefd�Zedk(r�ddlZej8d��Zej=ddde
��ej=ddde��ej=ddede��ej=ddede��ej=dd ed!e��ejA�Z!ee!jDe!jFe!jHe!jJe!jL�"�Z'e(ejRe'��yy)#�N)�
atomic_helper�dmi�helpers�sources�
url_helper�util)�ec2zhttp://169.254.169.254z1.0i��
��Exoscalec�T��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
ed	��Z�xZ
S)
�DataSourceExoscaler�xc����tt|�|||�tj	d�|j
j
dt�|_|j
j
dt�|_
t|j
j
dt��|_
|j
j
dt�|_|j
j
dt �|_i|_y)Nz$Initializing the Exoscale datasource�metadata_url�api_version�password_server_port�timeout�retries)�superr�__init__�LOG�debug�ds_cfg�get�METADATA_URLr�API_VERSIONr�int�PASSWORD_SERVER_PORTr�URL_TIMEOUT�url_timeout�URL_RETRIES�url_retries�extra_config)�self�sys_cfg�distro�paths�	__class__s    ��F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceExoscale.pyrzDataSourceExoscale.__init__s����
� �$�0��&�%�H��	�	�8�9� �K�K�O�O�N�L�I����;�;�?�?�=�+�F���$'��K�K�O�O�2�4H�I�%
��!� �;�;�?�?�9�k�B����;�;�?�?�9�k�B������c��d}|jjd�}tj|�}|j	d|zd�rt
j
d�yy)z<Adjust set_passwords module to run 'always' during each boot�
set_passwords�sem�config_Nz5Overriding module set_passwords with frequency always)r(�
get_ipath_curr�FileSemaphores�clearrr)r%�cfg�is_new_instance�mod�sem_path�
sem_helpers      r*�activatezDataSourceExoscale.activate*sS�����:�:�+�+�E�2���+�+�H�5�
����I��O�T�2��I�I�M�N�3r+c���dj|j|j�}tj|g|j
|jtj��\}}t|�S)z.Wait for the metadata service to be reachable.z{}/{}/meta-data/instance-id)�urls�max_waitr�	status_cb)
�formatrrr�wait_for_url�url_max_waitr!r�critical�bool)r%r�url�	_responses    r*�wait_for_metadata_servicez,DataSourceExoscale.wait_for_metadata_service9se��5�;�;����t�/�/�
��$�0�0����&�&��$�$��l�l�	
���Y��C�y�r+c���tjtjd|j��}|siSt|j|j|j|j|j�S)zw
        Crawl the metadata service when available.

        @returns: Dictionary of crawled metadata content.
        z waiting for the metadata service��logfunc�msg�func)r�log_timer�inforD�
read_metadatarrrr!r#)r%�metadata_readys  r*�crawl_metadataz!DataSourceExoscale.crawl_metadataIsi������H�H�2��/�/�
����I���������%�%�������
�	
r+c��tjtjd|j��}|sy|d|_|d|_|jd�}i}|rd|ddid	�}tj|j|g�|_	y)
z�Fetch the user data, the metadata and the VM password
        from the metadata service.

        Please refer to the datasource documentation for details on how the
        metadata server and password server are crawled.
        zCrawl of metadata servicerFF�	user-data�	meta-data�passwordT�expire)�
ssh_pwauthrR�chpasswd)
rrJrrrN�userdata_raw�metadatar�
mergemanydictr$)r%�datarR�password_configs    r*�	_get_datazDataSourceExoscale._get_data`s����}�}��I�I�+��$�$�
���� ��-����[�)��
��8�8�J�'�����#�$��e���O�!�.�.�
�
�
��0�
���r+c��|jS�N)r$)r%s r*�get_config_objz!DataSourceExoscale.get_config_obj�s��� � � r+c�R�tjd�jt�S)Nzsystem-product-name)r�
read_dmi_data�
startswith�EXOSCALE_DMI_NAME�r+r*�	ds_detectzDataSourceExoscale.ds_detect�s$��� � �!6�7�B�B��
�	
r+)�__name__�
__module__�__qualname__�dsnamer?rr8rDrNr[r^�staticmethodrd�
__classcell__)r)s@r*rrsA���
�F��L��
O�� 
�.)�V!��
��
r+rc�6�tj|t�Sr])r�list_from_depends�datasources)�dependss r*�get_datasource_listro�s���$�$�W�k�:�:r+c���dj|||�}tj|dddi||��}|jj	d�}|dvrytj|dddi||��|S)	z�Obtain the VM's password if set.

    Once fetched the password is marked saved. Future calls to this method may
    return empty string or 'saved_password'.z	{}:{}/{}/N�DomU_Request�send_my_password)�ssl_details�headersrrzutf-8)��saved_passwordrv)r=r�read_file_or_url�contents�decode)rrrr!r#�password_url�responserRs        r*�get_passwordr|�s����%�%��*�K��L��*�*����!3�4����H�� � �'�'��0�H��)�)��������!1�2�����Or+c�~�i}||d<	tj||||��|d<tj||||��|d<	t|||||��|d<|S#t$r(}t	j
td||�icYd}~Sd}~wwxYw#t$r(}t	j
td	|||�Yd}~|Sd}~wwxYw)
z8Query the metadata server and return the retrieved data.�_metadata_api_version)rrrPrQz(failed reading from metadata url %s (%s)N)rrrr#r!rRz2failed to read from password server url %s:%s (%s))r	�get_instance_userdata�get_instance_metadata�	Exceptionr�logexcrr|)rrrr!r#�crawled_metadata�es       r*rLrL�s�����0;��,�-��(+�(A�(A���{�K�)
���%�),�(A�(A���{�K�)
���%�
�'3�#�%�!5�#�#�(
���$� ���/������;�\�1�	
��	��	���
�����@�� �
�	
�	
����
�s5�8A�B�	B� B�=B�B�	B<�B7�7B<�__main__zQuery Exoscale Metadata)�descriptionz
--endpoint�URLz The url of the metadata service.)�metavar�help�defaultz	--version�VERSIONz.The version of the metadata endpoint to query.z	--retries�NUMz,The number of retries querying the endpoint.)r��typer�r�z	--timeoutz.The time in seconds to wait before timing out.z--password-port�PORTz/The port on which the password endpoint listens)rrrr!r#)*�logging�	cloudinitrrrrrr�cloudinit.sources.helpersr	�	getLoggerrerrrrr r"rb�
DataSourcer�DEP_FILESYSTEM�DEP_NETWORKrmror|rL�argparse�ArgumentParser�parser�add_argumentr�
parse_args�args�endpoint�version�
password_portrrrY�print�
json_dumpsrcr+r*�<module>r�s����L�L�)��g����!��'������������{
��+�+�{
�@�'�0�0�'�2E�2E�F�G���;�
��-���#�N��-���(�V�z���
$�X�
$�
$�1J�
K�F�
�����
/��	�������
=��	�������
�
;���������
�
=���������
�
>�$�������D���]�]��L�L�!�/�/��L�L��L�L��D�
�
"�-�
"�
"�4�
(�)�ar+

Zerion Mini Shell 1.0