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__/DataSourceRbxCloud.cpython-311.pyc
�

܍~cU��"�dZddlZddlZddlZddlZddlmZddlmZ	ddlm
Z
mZmZddl
mZmZe	je��ZdZd�Zd	ed
efd�Zd
ejefd�Zd
�Zd�Zd�Zd�Zd�ZGd�de
j��Z e e
j!ffgZ"d�Z#dS)zr
This file contains code used to gather the user data passed to an
instance on rootbox / hyperone cloud platforms
�N)�IPv4Address)�log)�sources�subp�util)�
EventScope�	EventTypez
/etc/hostsc��tjtd���}|rt�d��dSt�d��dS)NT)�quietz5/etc/hosts exists - setting manage_etc_hosts to FalseFz=/etc/hosts does not exists - setting manage_etc_hosts to True)r�	load_file�	ETC_HOSTS�LOG�debug)�hostss �F/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceRbxCloud.py�get_manage_etc_hostsrsN���N�9�D�1�1�1�E����	�	�I�J�J�J��u��I�I�M�N�N�N��4��inc�returnc	�t�tttt|����|z����S�N)�strr�int)�addrrs  r�increment_ipr#s-���{�3�{�4�0�0�1�1�C�7�8�8�9�9�9rc�D�|t|d��t|d��gS)z�Return a list of 3 IP addresses: [addr, addr + 2, addr + 3]

    @param addr: an object that is passed to IPvAddress
    @return: list of strings
    ��)r)rs r�
get_three_ipsr's+��	
��T�1����T�1����rc�2�tjdg|z��S)z�
    Uses the preferred cloud-init subprocess def of subp.subp
    and runs arping.  Breaking this to a separate function
    for later use in mocking and unittests
    �arping)r)�cmds r�_sub_arpr#4s���9�h�Z�#�%�&�&�&rc	��d}|jdvrd}|D]h}	tdd||d|dg���$#tj$r3}t�d|d|d|��Yd}~�ad}~wwxYwdS)	Nz-S)�fedora�centos�rhelz-sz-c�2�source�destinationz&Failed to arping from "%s" to "%s": %s)�namer#r�ProcessExecutionErrorr�warning)�items�distro�source_param�item�errors     r�gratuitous_arpr3=s����L�
�{�2�2�2�������
	���s�L�$�x�.�$�}�:M�N�
�
�
�
���)�		�		�		�
�K�K�8��X���]�#��	
�
�
�
�
�
�
�
�����			�����s� 4�A6�)A1�1A6c���ttjd��tjd��z��}|sdS|D]}	tj|tgd����}|r|cS�(#t
$r }|jtjkr�Yd}~�Md}~wtj$rtj	td|��Y�|wxYwt�dd	�|����dS)
zAReturns False (not found or error) or a dictionary with metadata.z
LABEL=CLOUDMDz
LABEL=cloudmdF)�vfat�fat�msdosfs)�device�callback�mtypeNz-Failed to mount %s when looking for user dataz0Did not find RbxCloud data, searched devices: %s�,)
�setr�find_devs_with�mount_cb�read_user_data_callback�OSError�errno�ENOENT�MountFailedError�logexcrr�join)�devicesr8�rbx_data�errs    r�get_mdrIRs?�����O�,�,�
�
�o�
.�
.�	/���G����u�����	��}��0�0�0�0����H�
�
 �����
 ���	�	�	��y�E�L�(�(��)�(�(�(�(������$�	�	�	��K��D�f�
�
�
�
�
�	����
�I�I�:�C�H�H�W�<M�<M�����5s�!A%�%
B:�/B
�
-B:�9B:c�:�dd�t|��D��d�S)z�Generate network configuration

    @param netadps: A list of network adapter settings

    @returns: A dict containing network config
    �c���g|]V\}�dd�t|�����d����fd��dD��d���WS)�physicalzeth{}�
macaddressc	���g|];}d|d�ddd�dd�dddd���<S)	�static�address�network�netmask�auto�gateway�dns�nameservers)�typerQrS�controlrU�dns_nameservers�)�.0�ip�netadps  �r�
<listcomp>z6generate_network_config.<locals>.<listcomp>.<listcomp>sn�������!)�#%�i�=�#)�)�#4�Y�#?�#)�#)�)�#4�Y�#?�+1�)�+<�U�+C�)�,�
	�	���rr])rXr+�mac_address�subnets)�formatr�lower)r\�ir^s  @rr_z+generate_network_config.<locals>.<listcomp>zs����
�
�
�&��6�##����s�1�v�v�.�.�%�l�3�9�9�;�;�����%�T�l����	
�
�
�
�
r)�version�config)�	enumerate)�netadpss r�generate_network_configriqs<���
�
�&'�w�/�/�'
�
�
���rc
��tjtjtj�|d��d������}tjtj�|d��d���}d|vsd	|vrtjtd
��dS|�di���d
��}|�di���dg��}d}|�di���d��r|ddd}t|d	��}||dd|ddgd�d�|d	D��ddd||dg|d|d�i|t��d�d�}t�d��t�|��|S)aThis callback will be applied by util.mount_cb() on the mounted
    drive.

    @param mount_dir: String representing path of directory where mounted drive
    is available

    @returns: A dict containing userdata, metadata and cfg based on metadata.
    z
cloud.jsonF)�fname�decode)�textz	user.dataT)rkr�vmr^z(Failed to load metadata. Invalid format.N�additionalMetadata�username�sshKeys�password�sha512�_idr+)zinstance-idzlocal-hostname�public-keysc�v�g|]6}|dD]+}t|dd��D]
}|d|d����,�7S)r]rRrUrQ)r)r*)r)r\r^r]�targets    rr_z+read_user_data_callback.<locals>.<listcomp>�sx��
�
�
���T�l�
�
��'��y�(9�)�(D�E�E�	
�
���)�}�V�<�<�
�
�
�
�
r�default_userzALL=(ALL) NOPASSWD:ALL)r+�gecos�sudo�passwd�lock_passwd�ssh_authorized_keys)�
ssh_pwauth�disable_root�system_info�network_config�manage_etc_hosts)�userdata�metadatar3�cfgzreturning DATA object:)r�	load_jsonr�os�pathrErDr�getrirr)�	mount_dir�	meta_data�	user_datarp�ssh_keys�hashrR�datas        rr?r?�s�����
�^��'�,�,�y�,�7�7��
�
�
����I�
���g�l�l�9�k�2�2�$����I��9����	� 9� 9���C�C�D�D�D��t��}�}�1�2�6�6�:�:�:�F�F�H��}�}�1�2�6�6�:�:�9�b�I�I�H��D��}�}�)�2�.�.�2�2�:�>�>�E��-�.�z�:�8�D��%�i��&9�:�:�G��$�T�?�5�1�'��o�f�5��
�
�

�
�#�H�-�
�
�
�� ��$�%�5�6�"�#(�+3�
!�!�	�&� 4� 6� 6�
�
���D�>�I�I�&�'�'�'��I�I�d�O�O�O��Krc��eZdZdZejejejej	hiZ
d�Zd�Zd�Z
ed���Zd�Zd�Zd�Zd	�Zd
S)�DataSourceRbxCloud�RbxCloudc�X�tj�||||��d|_dSr)r�
DataSource�__init__�seed)�self�sys_cfgr/�pathss    rr�zDataSourceRbxCloud.__init__�s*����#�#�D�'�6�5�A�A�A���	�	�	rc�Z�tj�|��}|�d|j�d�S)Nz [seed=�])rr��__str__r�)r��roots  rr�zDataSourceRbxCloud.__str__�s-���!�)�)�$�/�/��!%���t�y�y�y�1�1rc��t��}|durdS|d|_|d|_|d|_|d|_dS)zw
        Metadata is passed to the launching instance which
        is used to perform instance configuration.
        Fr�r�r3r�T)rI�userdata_rawr�r3r�)r�rGs  r�	_get_datazDataSourceRbxCloud._get_data�sT��
�8�8���u����5�$�Z�0��� ��,��
�&�'7�8����E�?����trc��|jdS)Nr��r��r�s rr�z!DataSourceRbxCloud.network_config�s���x�(�)�)rc��|jdS)Nru)r�r�s r�get_public_ssh_keysz&DataSourceRbxCloud.get_public_ssh_keys�s���}�]�+�+rc��|jSr)r�r�s r�get_userdata_rawz#DataSourceRbxCloud.get_userdata_raw�s��� � rc��|jSrr�r�s r�get_config_objz!DataSourceRbxCloud.get_config_obj�s	���x�rc�:�t|j|j��dSr)r3r/)r�r��is_new_instances   r�activatezDataSourceRbxCloud.activates���t�*�D�K�8�8�8�8�8rN)�__name__�
__module__�__qualname__�dsnamer�NETWORKr	�BOOT_NEW_INSTANCE�BOOT�BOOT_LEGACY�default_update_eventsr�r�r��propertyr�r�r�r�r�r[rrr�r��s�������
�F����'��N��!�
������2�2�2�����*�*��X�*�,�,�,�!�!�!����9�9�9�9�9rr�c�6�tj|t��Sr)r�list_from_depends�datasources)�dependss r�get_datasource_listr�s���$�W�k�:�:�:r)$�__doc__rAr��os.path�typing�	ipaddressr�	cloudinitr�loggingrrr�cloudinit.eventrr	�	getLoggerr�rr
rrrr�Listrr#r3rIrir?r�r��DEP_FILESYSTEMr�r�r[rr�<module>r�s�����
����	�	�	�	�����
�
�
�
�!�!�!�!�!�!�$�$�$�$�$�$�)�)�)�)�)�)�)�)�)�)�1�1�1�1�1�1�1�1��g���!�!���	����:�C�:�C�:�:�:�:�
�6�;�s�+�
�
�
�
�'�'�'����*���>���B?�?�?�D.9�.9�.9�.9�.9��+�.9�.9�.9�f�'�0�2�3���;�;�;�;�;r