HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/sources/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceExoscale.cpython-311.pyc
�

܍~c�#����ddlmZmZddlmZddlmZmZmZddlm	Z	ej
e��ZdZ
dZdZdZd	Zd
ZGd�dej��ZeejejffgZd
�Ze
eeeefd�Ze
eeeefd�Zedkr�ddlZejd���Ze�ddde
���e�ddde���e�ddede���e�dded e���e�d!d"ed#e���e� ��Z!ee!j"e!j#e!j$e!j%e!j&�$��Z'e(ej)e'����dSdS)%�)�dmi�helpers)�log)�sources�
url_helper�util)�ec2zhttp://169.254.169.254z1.0i��
��Exoscalec�J��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Z�xZS)
�DataSourceExoscaler�xc�*��tt|���|||��t�d��|j�dt��|_|j�dt��|_
t|j�dt����|_
|j�dt��|_|j�dt ��|_i|_dS)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�0��&�%�H�H�H��	�	�8�9�9�9� �K�O�O�N�L�I�I����;�?�?�=�+�F�F���$'��K�O�O�2�4H�I�I�%
�%
��!� �;�?�?�9�k�B�B����;�?�?�9�k�B�B��������c���d}|j�d��}tj|��}|�d|zd��rt
�d��dSdS)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*sp�����:�+�+�E�2�2���+�H�5�5�
����I��O�T�2�2�	O��I�I�M�N�N�N�N�N�	O�	Or+c��d�|j|j��}tj|g|j|jtj���\}}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����&��$��l�	
�
�
���Y��C�y�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_metadataIsg�����H�2��/�
�
�
���	��I�������%�����
�
�	
r+c�<�|���sdStjtjd|j���}|sdS|d|_|d|_|�d��}i}|rd|ddid	�}tj	|j
|g��|_
dS)
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.
        FzCrawl of metadata servicerF�	user-data�	meta-data�passwordT�expire)�
ssh_pwauthrR�chpasswd)�_is_platform_viablerrJrrrN�userdata_raw�metadatar�
mergemanydictr$)r%�datarR�password_configs    r*�	_get_datazDataSourceExoscale._get_data`s����'�'�)�)�	��5��}��I�+��$�
�
�
���	��5� ��-����[�)��
��8�8�J�'�'�����
	�#�$��e����O�!�.�
�
��0�
�
����tr+c��|jS�N)r$�r%s r*�get_config_objz!DataSourceExoscale.get_config_obj�s��� � r+c�Z�tjd���t��S)Nzsystem-product-name)r�
read_dmi_data�
startswith�EXOSCALE_DMI_NAMEr_s r*rVz&DataSourceExoscale._is_platform_viable�s)��� �!6�7�7�B�B��
�
�	
r+)
�__name__�
__module__�__qualname__�dsnamer?rr8rDrNr\r`rV�
__classcell__)r)s@r*rrs��������
�F��L������
O�
O�
O���� 
�
�
�.,�,�,�\!�!�!�
�
�
�
�
�
�
r+rc�6�tj|t��Sr^)r�list_from_depends�datasources)�dependss r*�get_datasource_listrn�s���$�W�k�:�:�:r+c���d�|||��}tj|dddi||���}|j�d��}|dvrdStj|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_passwordru)r=r�read_file_or_url�contents�decode)rrrr!r#�password_url�responserRs        r*�get_passwordr{�s����%�%��*�K���L��*����!3�4������H�� �'�'��0�0�H��)�)�)��t������!1�2��������Or+c��i}||d<	tj||||���|d<tj||||���|d<n5#t$r(}t	jtd||��icYd}~Sd}~wwxYw	t|||||���|d<n4#t$r'}t	jtd	|||��Yd}~nd}~wwxYw|S)
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�sR����0;��,�-��(+�(A���{�K�)
�)
�)
���%�),�(A���{�K�)
�)
�)
���%�%���������;�\�1�	
�	
�	
��	�	�	�	�	�	�����	����
�'3�#�%�!5�#�#�(
�(
�(
���$�$���
�
�
����@�� �
�	
�	
�	
�	
�	
�	
�	
�	
�����
�����s5�6A�
A2�
A-�'A2�-A2�6B�
B?�B:�:B?�__main__NzQuery 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#)*�	cloudinitrrr�loggingrrr�cloudinit.sources.helpersr	�	getLoggerrerrrrr r"rd�
DataSourcer�DEP_FILESYSTEM�DEP_NETWORKrlrnr{rL�argparse�ArgumentParser�parser�add_argumentr�
parse_args�args�endpoint�version�
password_portrrrZ�print�
json_dumps�r+r*�<module>r�s���#�"�"�"�"�"�"�"�$�$�$�$�$�$�/�/�/�/�/�/�/�/�/�/�)�)�)�)�)�)��g���!�!��'������������}
�}
�}
�}
�}
��+�}
�}
�}
�D�'�0�'�2E�F�G���;�;�;�
��-���#�#�#�#�N��-���(�(�(�(�V�z����O�O�O�
$�X�
$�1J�
K�
K�
K�F�
�����
/��	���������
=��	���������
�
;�����������
�
=�����������
�
>�$����������D��=��]��L�!�/��L��L����D�
�E�/�$�/�$�
�
� � � � � �a�r+