HOME


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

܍~c6$����ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZdZ
dZGd�dej���ZGd	�d
e��ZegZdd�Zd�Zdd
�Zd�Zd�Zd�Zdd�ZdS)�N)�util)�get_devicelist�read_sys_net_safez#/run/initramfs/open-iscsi.interface�disabledc�^�eZdZdZejdefd���Zejdefd���Z	dS)�InitramfsNetworkConfigSourcezBABC for net config sources that read config written by initramfses�returnc��dS)zAIs this initramfs config source applicable to the current system?N���selfs �7/usr/lib/python3/dist-packages/cloudinit/net/cmdline.py�
is_applicablez*InitramfsNetworkConfigSource.is_applicable�����c��dS)z;Render a v1 network config from the initramfs configurationNrrs r�
render_configz*InitramfsNetworkConfigSource.render_config rrN)
�__name__�
__module__�__qualname__�__doc__�abc�abstractmethod�boolr�dictrrrrrrsz������L�L���P�t�P�P�P���P�	��J�t�J�J�J���J�J�Jrr)�	metaclassc�2�eZdZdZdd�Zdefd�Zdefd�ZdS)�KlibcNetworkConfigSourcez�InitramfsNetworkConfigSource for klibc initramfs (i.e. Debian/Ubuntu)

    Has three parameters, but they are intended to make testing simpler, _not_
    for use in production code.  (This is indicated by the prepended
    underscores.)
    Nc��||_||_||_|j�t��|_|j�t	j��|_|j�4i|_t
��D] }t|d��}|r
||j|<�dSdS)N�address)�_files�
_mac_addrs�_cmdline�_get_klibc_net_cfg_filesr�get_cmdlinerr)r
r!r"r#�k�mac_addrs      r�__init__z!KlibcNetworkConfigSource.__init__-s������$��� ��
��;��2�4�4�D�K��=� � �,�.�.�D�M��?�"� �D�O�#�%�%�
2�
2��,�Q�	�:�:���2�)1�D�O�A�&��#�"�
2�
2rr	c���|jrotj|j��D]/}|�d��s|�d��rdS�0t
j�t��rdSdS)aD
        Return whether this system has klibc initramfs network config or not

        Will return True if:
            (a) klibc files exist in /run, AND
            (b) either:
                (i) ip= or ip6= are on the kernel cmdline, OR
                (ii) an open-iscsi interface file is present in the system
        zip=zip6=TF)	r!�shlex�splitr#�
startswith�os�path�exists�_OPEN_ISCSI_INTERFACE_FILE)r
�items  rrz&KlibcNetworkConfigSource.is_applicable?s}���;�	���D�M�2�2�
 �
 ���?�?�5�)�)� �T�_�_�V�-D�-D� ��4�4� ��w�~�~�8�9�9�
��t��urc�8�t|j|j���S)N)�files�	mac_addrs)�config_from_klibc_net_cfgr!r"rs rrz&KlibcNetworkConfigSource.render_configRs#��(��+��o�
�
�
�	
r)NNN)	rrrrr(rrrrrrrrr%sh��������2�2�2�2�$�t�����&
�t�
�
�
�
�
�
rrc��|�i}tj|��}	d|vr|dn|d}n"#t$r}td��|�d}~wwxYw|�d|�d����}|s|�d��rd}nd	}|d
vrtd|z���d|gd
�}||vr|||d<dD�]?}|dz|vr�|�|dz|��}|d	krd}|dd�}	|dkr||dz|	d<dD])}
||
z|vr |||
z|	|
���<�*g}dD]\}|�||z��}
|
r@t
|
�d����r|�|||z���]|rP||	d<|�d��}|r4d|vr|�	d��|	d<n|�	��|	d<|d�|	����A||fS)a�Convert a klibc written shell content file to a 'config' entry
    When ip= is seen on the kernel command line in debian initramfs
    and networking is brought up, ipconfig will populate
    /run/net-<name>.cfg.

    The files are shell style syntax, and examples are in the tests
    provided here.  There is no good documentation on this unfortunately.

    DEVICE=<name> is expected/required and PROTO should indicate if
    this is 'none' (static) or 'dhcp' or 'dhcp6' (LP: #1621507).
    note that IPV6PROTO is also written by newer code to address the
    possibility of both ipv4 and ipv6 getting addresses.

    Full syntax is documented at:
    https://git.kernel.org/pub/scm/libs/klibc/klibc.git/plain/usr/kinit/ipconfig/README.ipconfig
    N�DEVICE�DEVICE6z&no 'DEVICE' or 'DEVICE6' entry in data�PROTO�	IPV6PROTO�filename�dhcp�none)r=r<�dhcp6zUnexpected value for PROTO: %s�physical)�type�name�subnets�mac_address)�IPV4�IPV6�ADDR�static�manual)r@�controlr )�NETMASK�	BROADCAST�GATEWAY)�DNS0�DNS1z:.0�dns_nameservers�DOMAINSEARCH�,�
dns_searchrB)
r�load_shell_content�KeyError�
ValueError�get�lower�len�strip�appendr+)�contentr4�datarA�e�proto�iface�pre�	cur_proto�subnet�key�dns�nskey�ns�searchs               r�_klibc_to_config_entryrh\s���$���	��"�7�+�+�D�J�!)�T�!1�!1�t�H�~�~�t�I������J�J�J��A�B�B��I�����J����

�H�H�W�d�h�h�{�3�3�4�4�E����8�8�J���	��E�E��E��-�-�-��9�E�A�B�B�B����
�
�E��y���(����m�� �'(�'(����<�t�#�#���H�H�S�7�]�E�2�2�	����� �I�#��9�9���� � � $�S�6�\� 2�F�9��7�	6�	6�C��S�y�D� � �&*�3��9�o��s�y�y�{�{�#����%�	.�	.�E����#��+�&�&�B��
.�c�"�(�(�5�/�/�*�*�
.��
�
�4��e��,�-�-�-���	:�(+�F�$�%��X�X�n�-�-�F��
:��&�=�=�+1�<�<��+<�+<�F�<�(�(�+1�<�<�>�>�F�<�(�
�i�����'�'�'�'���;�s�/�
A�A	�	Ac�T�tjd��tjd��zS)Nz/run/net-*.confz/run/net6-*.conf)�globrrrr$r$�s#���9�&�'�'�$�)�4F�*G�*G�G�Grc��|�t��}g}i}|D�]4}ttj|��|���\}}||vr�||d}|�d��|�d��krktd�|d�||d��|�d��|�d��������|d�|d��||d�	|����|g|d	�||<|�	|����6|d
d�S)N)r4�entryrCzedevice '{name}' was defined multiple times ({files}) but had differing mac addresses: {old} -> {new}.� r3)rAr3�old�newrB)r3rl�)�config�version)
r$rhr�	load_filerVrU�format�join�extendrZ)r3r4�entries�names�cfg_filerArl�prevs        rr5r5�sl���}�(�*�*���G��E��"�"��,��N�8�$�$�	�
�
�
���e��5�=�=���;�w�'�D��x�x�
�&�&�%�)�)�M�*B�*B�B�B� �H�HN��!�!�h�h�u�T�{�7�';�<�<� �H�H�]�3�3�!�I�I�m�4�4�	IO�I�I����
��O�"�"�5��#3�4�4�4��$�K�� �'�'��1�1�1�1�%-�J��?�?�E�$�K��N�N�5�!�!�!�!��!�,�,�,rc��tD]6}|��}|���s�!|���cSdS)a
    Return v1 network config for initramfs-configured networking (or None)

    This will consider each _INITRAMFS_CONFIG_SOURCES entry in turn, and return
    v1 network configuration for the first one that is applicable.  If none are
    applicable, return None.
    N)�_INITRAMFS_CONFIG_SOURCESrr)�src_cls�
cfg_sources  r�read_initramfs_configr�sR��-�*�*���W�Y�Y�
��'�'�)�)�	���'�'�)�)�)�)�)��4rc��tj|��5}d}	tjd|���}|���|r|���cddd��S#t$r'|cY|r|���cddd��SwxYw#|r|���wwxYw#1swxYwYdS)N�rb)�mode�fileobj)�io�BytesIO�gzip�GzipFile�read�close�IOError)�blob�iobuf�gzfps   r�_decomp_gzipr��s6��	��D�	�	�	�U���	��=�d�E�:�:�:�D��9�9�;�;��
��
�
����	�	�	�	�	�	�	�	��
�	�	�	��K�K��
��
�
����	�	�	�	�	�	�	�	�
	������
��
�
�����
����	�	�	�	����	�	�	�	�	�	sF�B5�)A%�B5�%B�1B�2B5�B�B�B2�2B5�5B9�<B9c��	tj|��}n-#ttf$rt	jd|��YdSwxYwt
|��S)z�Decode a string base64 encoding, if gzipped, uncompress as well

    :return: decompressed unencoded string of the data or empty string on
       unencoded data.
    z`Expected base64 encoded kernel commandline parameter network-config. Ignoring network-config=%s.�)�base64�	b64decode�	TypeErrorrU�logging�errorr�)r\r�s  r�_b64dgzr��sn������%�%�����z�"�����
�
;��	
�	
�	
�
�r�r�
��������s��&A�Ac�0�|�tj��}d|vr|d}|���D]3}|�d��r|�dd��d}�4|r0|tkrddiStjt
|����SdS)Nznetwork-config=�=rprqr)rr%r+r,�&KERNEL_CMDLINE_NETWORK_CONFIG_DISABLED�	load_yamlr�)�cmdline�data64�toks   r�read_kernel_cmdline_configr�s������"�$�$���G�#�#����=�=�?�?�	.�	.�C��~�~�/�0�0�
.����3��*�*�1�-����	3��?�?�?� �*�-�-��>�'�&�/�/�2�2�2��4r)N)NN)rr�rjr�r�r�r-r*�	cloudinitr�
cloudinit.netrrr0r��ABCMetarrr|rhr$r5rr�r�r�rrr�<module>r�s����
�
�
�
�
�
�
���������	�	�	�	�����	�	�	�	�����������;�;�;�;�;�;�;�;�B��)3�&�	J�	J�	J�	J�	J�S�[�	J�	J�	J�	J�1
�1
�1
�1
�1
�;�1
�1
�1
�h6�6��Z�Z�Z�Z�zH�H�H�-�-�-�-�>���$������&�����r