%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__/DataSourceVMware.cpython-312.pyc

�

���f/���6�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZmZmZddlmZddlmZmZmZdZej0e�ZdZdZd	Zd
ZdZdZ d
Z!dZ"dZ#dZ$dZ%dZ&dZ'Gd�dejP�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d �Z4d!�Z5d"�Z6d#�Z7d$�Z8d%�Z9d&�Z:d'�Z;e)ejxffe)ejxejzffgZ>d(�Z?d)�Z@d4d*�ZAd+�ZBd,eCd-eCfd.�ZDd,eCd-eCfd/�ZEd0�ZFd1�ZGd2�ZHed3k(reH�yy)5z�Cloud-Init DataSource for VMware

This module provides a cloud-init datasource for VMware systems and supports
multiple transports types, including:

    * EnvVars
    * GuestInfo
    * IMC (Guest Customization)
�N)�
atomic_helper�dmi�log�net�netinfo�sources�util)�guestcust_util)�ProcessExecutionError�subp�whichz/sys/class/dmi/id/product_uuidzNo value found�envvar�	guestinfo�imc�redactzcleanup-guestinfo�
VMX_GUESTINFOz---z
local-ipv4z
local-ipv6zwait-on-network�ipv4�ipv6c���eZdZdZdZdd�Zdeddf�fd�Zd�Zd	�Z	d
�Z
d�Zd�Ze
d
��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�DataSourceVMwareav
    Setting the hostname:
        The hostname is set by way of the metadata key "local-hostname".

    Setting the instance ID:
        The instance ID may be set by way of the metadata key "instance-id".
        However, if this value is absent then the instance ID is read
        from the file /sys/class/dmi/id/product_uuid.

    Configuring the network:
        The network is configured by setting the metadata key "network"
        with a value consistent with Network Config Versions 1 or 2,
        depending on the Linux distro's version of cloud-init:

            Network Config Version 1 - http://bit.ly/cloudinit-net-conf-v1
            Network Config Version 2 - http://bit.ly/cloudinit-net-conf-v2

        For example, CentOS 7's official cloud-init package is version
        0.7.9 and does not support Network Config Version 2.

        imc transport:
            Either Network Config Version 1 or Network Config Version 2 is
            supported which depends on the customization type.
            For LinuxPrep customization, Network config Version 1 data is
            parsed from the customization specification.
            For CloudinitPrep customization, Network config Version 2 data
            is parsed from the customization specification.

        envvar and guestinfo transports:
            Network Config Version 2 data is supported as long as the Linux
            distro's cloud-init package is new enough to parse the data.
            The metadata key "network.encoding" may be used to indicate the
            format of the metadata key "network". Valid encodings are base64
            and gzip+base64.
    �VMwareNc��tjj|||||�i|_d|_d|_d|_t|jdft|jdft|jdfg|_
y)NFT)r�
DataSource�__init__�cfg�data_access_method�rpctool�
rpctool_fn�DATA_ACCESS_METHOD_ENVVAR�get_envvar_data_fn�DATA_ACCESS_METHOD_GUESTINFO�get_guestinfo_data_fn�DATA_ACCESS_METHOD_IMC�get_imc_data_fn� possible_data_access_method_list)�self�sys_cfg�distro�paths�ud_procs     �D/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceVMware.pyrzDataSourceVMware.__init___sw�����#�#�D�'�6�5�'�J����"&���������'��(?�(?��G�
)�4�+E�+E�t�L�
#�T�%9�%9�4�@�1
��-��ci_pkl_version�returnc	�8��t�|�|�dD]}t||�r�t||d��t|d�s
t|di�t|d�sDt|dt|j
dft|jdft|jdfg�yy)N)rrrr%FT)
�super�	_unpickle�hasattr�setattrrr r!r"r#r$)r&r-�attr�	__class__s   �r+r1zDataSourceVMware._unpicklets����
���.�)�-�	*�D��4��&���d�D�)�	*��t�U�#��D�%��$��t�?�@���2�2��/�/���5��2�2���
,�T�-A�-A�4�H��
�Ar,c�d�tjj|�}|�d|j�d�S)Nz [seed=�])rr�__str__r)r&�roots  r+r8zDataSourceVMware.__str__�s)���!�!�)�)�$�/��!%�t�'>�'>�?�?r,c���d\}}}|jD]-\}}}|rt�s�|�\}}}|s|s|s�&||_n|jstj	d�ytjd|j
��tt|��|_	||_
||_|j�|js|js|jryy)a�
        _get_data loads the metadata, userdata, and vendordata from one of
        the following locations in the given order:

            * envvars
            * guestinfo
            * imc

        Please note when updating this function with support for new data
        transports, the order should match the order in the dscheck_VMware
        function from the file ds-identify.
        �NNNz)failed to find a valid data access methodFzusing data access method %sT)
r%�is_vmware_platformr�LOG�debug�info�_get_subplatform�process_metadata�load_json_or_yaml�metadata�userdata_raw�vendordata_raw�redact_keys)r&�md�ud�vdr�get_data_fn�require_vmware_platforms       r+�	_get_datazDataSourceVMware._get_data�s���"&�
��B���
2�
2�	
	�
���#�&�/A�/C��&�=�L�R��R��R�2�*<��'��
	��&�&��I�I�A�B�����.��0E�0E�0G�H�)�):�2�)>�?��
����!���	
�����=�=�D�-�-��1D�1D��r,c��t|j�}tjd|�t	||j
|j�tj|j|g�|_|j�y)a(setup(is_new_instance)

        This is called before user-data and vendor-data have been processed.

        Unless the datasource has set mode to 'local', then networking
        per 'fallback' or per 'network_config' will have been written and
        brought up the OS at this point.
        zgot host-info: %sN)
�wait_on_networkrCr=r?�advertise_local_ip_addrsrrr	�
mergemanydict�persist_instance_data)r&�is_new_instance�	host_infos   r+�setupzDataSourceVMware.setup�sb��$�D�M�M�2�	����$�i�0�	!��D�L�L�$�/�/�J�
�*�*�D�M�M�9�+E�F��
�	
�"�"�$r,c���d}|jtk(rt}nD|jtk(rt}n*|jt
k(rt}ntjS|j�d|d��d�S)Nz (rC�))	rr�get_guestinfo_envvar_key_namer!�get_guestinfo_key_namer#�get_imc_key_namer�METADATA_UNKNOWN)r&�get_key_name_fns  r+r@z!DataSourceVMware._get_subplatform�sl�����"�"�&?�?�;�O�
�
$�
$�(D�
D�4�O�
�
$�
$�(>�
>�.�O��+�+�+�
�#�#��J�'�
�	
r,c��|jS�N)r�r&s r+�get_config_objzDataSourceVMware.get_config_obj�s���x�x�r,c���d|jvrtjd�n>tjd�d|jj	�i|jd<|jddS)N�networkzusing metadata network configzusing fallback network config�config)rCr=r>r(�generate_fallback_configr^s r+�network_configzDataSourceVMware.network_config�s`����
�
�%��I�I�5�6��I�I�5�6��$�+�+�>�>�@�(�D�M�M�)�$��}�}�Y�'��1�1r,c�B�|jrd|jvr|jdSttd�5}t|j	��j�j
�|jd<|jdcddd�S#1swYyxYw)Nzinstance-id�r)rC�open�PRODUCT_UUID_FILE_PATH�str�read�rstrip�lower)r&�id_files  r+�get_instance_idz DataSourceVMware.get_instance_ids~���=�=�]�d�m�m�;��=�=��/�/�
�(�#�
.�	0�'�+.�w�|�|�~�+>�+E�+E�+G�+M�+M�+O�D�M�M�-�(��=�=��/�	0�	0�	0�s�AB�Bc��|jrB|jtk(r/t�r%tj	d|j��yy)Nz"Cache fallback is allowed for : %sTF)rr#r<r=r>r@r^s r+�check_if_fallback_is_allowedz-DataSourceVMware.check_if_fallback_is_allowedsB���#�#��'�'�+A�A�"�$��I�I�4�d�6K�6K�6M�
��r,c�x�dD]4}||jvs�tj|j|�cSgS)N)zpublic-keys-data�public_keys_datazpublic-keys�public_keys)rCr�normalize_pubkey_data)r&�key_names  r+�get_public_ssh_keysz$DataSourceVMware.get_public_ssh_keyssD��
�	N�H��4�=�=�(��4�4�T�]�]�8�5L�M�M�	N��	r,c��d}t|jvr|jt}n%t|jvr|jt}|jtk(r"t||j|j�yyr])�REDACTrC�CLEANUP_GUESTINFOrr!�guestinfo_redact_keysrr)r&�keys_to_redacts  r+rFzDataSourceVMware.redact_keys(sh�����T�]�]�"�!�]�]�6�2�N�
�$�-�-�
/�!�]�]�+<�=�N��"�"�&B�B�!�����d�o�o�
�Cr,c��d\}}}tjjtd�r!t	d�}t	d�}t	d�}|||fS)z<
        check to see if there is data via env vars
        r;�rC�userdata�
vendordata)�os�environ�getr�guestinfo_envvar)r&rGrHrIs    r+r z#DataSourceVMware.get_envvar_data_fn6sK��&�
��B��
�:�:�>�>�-��,�!�*�-�B�!�*�-�B�!�,�/�B��B��|�r,c�8�td�}td�}|r(||_t|_tjd|�|r*|s||_t|_tjd|�|jstjd�yd�}	||j|j�S#t$r�}tjtd|j|�|r|j|k(rYd	}~y|stjd
�Yd	}~ytjd�||_t|_	||j|j�cYd	}~S#t$r-tjtd|j|�YYd	}~ywxYwd	}~wwxYw)zK
        check to see if there is data via the guestinfo transport
        �vmtoolsdzvmware-rpctoolzdiscovered vmware-rpctool: %szdiscovered vmtoolsd: %szno rpctool discoveredr;c��d\}}}tjd|�td||�}td||�}td||�}|||fS)Nr;zquery guestinfo with %srCr~r)r=r?r)rrrGrHrIs     r+�query_guestinfoz?DataSourceVMware.get_guestinfo_data_fn.<locals>.query_guestinfo^sR��)�J�B��B��H�H�.��8��:�w�
�;�B��:�w�
�;�B��<��*�=�B��r�2�:�r,z%Failed to query guestinfo with %s: %sNz$vmtoolsd fallback option not presentzfallback to vmtoolsd)r
r�exec_vmware_rpctoolrr=r>�
exec_vmtoolsd�	Exceptionr	�logexcr?)r&r��vmware_rpctoolr��errors     r+r"z&DataSourceVMware.get_guestinfo_data_fnBsP��
��$���/�0���)�D�L�1�D�O��I�I�5�~�F��"�'���"/����I�I�/��:��|�|��I�I�-�.�%�	�&	*�#�4�<�<����A�A���"	*��K�K��7�����	
��D�L�L�H�4�)�����?�@�)��H�H�+�,�#�D�L�+�D�O�

*�&�t�|�|�T�_�_�E�E���
*�����;��L�L��	�*�
*��5"	*�sH�B0�0	F�97F�5F�'F�9E�F�/F�
F�F�F�Fc��d\}}}tj|j�}tj|j�}|s|st
j
d�|||fStj�s|||fStj|j�}|�|||fStjj|�}tj|�}tj|�\}	}
|	rr|rpt
j
d�tj|jj |jj#d�|||j$�\}}}|_nH|
r1|r/t
j
d�tj(|�\}}}nt
j
d�t+j,|�|||fS)zN
        check to see if there is data via vmware guest customization
        r;z-Customization for VMware platform is disabledz3Getting data via VMware customization configuration�scriptszFGetting data via VMware raw cloudinit data customization configurationz1No allowed customization configuration data found)r
�is_vmware_cust_enabledr'�is_raw_data_cust_enabled�ds_cfgr=r>�is_cust_plugin_available�get_cust_cfg_filer��path�dirname�parse_cust_cfg�get_cust_cfg_type�get_data_from_imc_cust_cfgr)�	cloud_dir�	get_cpathr(r�#get_data_from_imc_raw_data_cust_cfgr	�del_dir)r&rGrHrI�allow_vmware_cust�allow_raw_data_cust�
cust_cfg_file�cust_cfg_dir�cust_cfg�is_vmware_cust_cfg�is_raw_data_cust_cfgs           r+r$z DataSourceVMware.get_imc_data_fn�s���&�
��B��+�A�A�$�,�,�O��,�E�E��K�K�
��!�)<��I�I�E�F���B�<���6�6�8���B�<��'�8�8����E�
�� ���B�<���w�w���}�5��!�0�0��?��
�,�,�X�6�	
�� ��"3��I�I�K�L�%3�%N�%N��
�
�$�$��
�
�$�$�Y�/������&�"�R��R���"�&9��I�I�.�
�*�M�M���L�R��R�
�I�I�I�J�	
���\�"��B��|�r,r])�__name__�
__module__�__qualname__�__doc__�dsnamer�intr1r8rLrTr@r_�propertyrdrnrprvrFr r"r$�
__classcell__)r5s@r+rr8s|���"�H�F�
�*�����4@�7�r%�8
�&��2��2�0�
�	��
�J*�X7r,rc��tjd�}|�tjd�yd|j	�vrtjd�yy)Nzsystem-product-namezNo system-product-name foundF�vmwarezNot a VMware platformT)r�
read_dmi_datar=r>rl)�system_types r+r<r<�sM���#�#�$9�:�K����	�	�0�1��	��*�*�,�	,��	�	�)�*��r,c�x�tjd||�d}|dvr@tjd||�tjt	j
|��}nI|dvr-tjd||�t	j
|�}ntjd|�|}tj|�S)z�
    decode returns the decoded string value of data
    key is a string used to identify the data being decoded in log messages
    z'Getting encoded data for key=%s, enc=%sN)zgzip+base64zgz+b64zDecoding %s format %s)�base64�b64zPlain-text data %s)r=r>r	�decomp_gzipr�b64d�
decode_binary)�key�enc_type�data�raw_datas    r+�decoder��s���
�I�I�7��h�G��H��,�,��	�	�)�8�S�9��#�#�M�$6�$6�t�$<�=��	�&�	&��	�	�)�8�S�9� �%�%�d�+���	�	�&��,������h�'�'r,c��tj|�}|j�}t|�dk(s	|tk(ry|S)a
    get_none_if_empty_val returns None if the provided value, once stripped
    of its trailing whitespace, is empty or equal to GUESTINFO_EMPTY_YAML_VAL.

    The return value is always a string, regardless of whether the input is
    a bytes class or a string.
    rN)r	r�rk�len�GUESTINFO_EMPTY_YAML_VAL)�vals r+�get_none_if_empty_valr��s:���
�
�S�
!�C�

�*�*�,�C�
�3�x�1�}��7�7���Jr,c��|r|r|sy|jt�}|r(tt|||�tj	d|�|jt
�}|r)tt
|||�tj	d|�yy)z�
    advertise_local_ip_addrs gets the local IP address information from
    the provided host_info map and sets the addresses in the guestinfo
    namespace
    Nz-advertised local ipv4 address %s in guestinfoz-advertised local ipv6 address %s in guestinfo)r��
LOCAL_IPV4�guestinfo_set_valuer=r?�
LOCAL_IPV6)rSrr�
local_ipv4�
local_ipv6s     r+rOrO�sq���G�:�����z�*�J���J�
�G�Z�H����@�*�M����z�*�J���J�
�G�Z�H����@�*�M�r,c�N�t|�}|r|Stjd|�y)z�
    handle_returned_guestinfo_val returns the provided value if it is
    not empty or set to GUESTINFO_EMPTY_YAML_VAL, otherwise None is
    returned
    �No value found for key %sN)r�r=r>)r�r�s  r+�handle_returned_guestinfo_valr�s(�� ��
$�C�
��
��I�I�)�3�/�r,c��y)Nzvmware-tools��r�s r+rYrYs��r,c��d|zS)Nz
guestinfo.r�r�s r+rXrX!s
���#��r,c�\�dt|�zj�jddd�S)Nzvmx.�.�_���)rX�upper�replacer�s r+rWrW%s+���+�C�0�0�7�7�9�A�A�#�s�B�O�Or,c�f�t|�}|syt|dz�}tt|�||�S)N�	.encoding)�guestinfo_envvar_get_valuer�rW)r�r�r�s   r+r�r�)s6��
$�S�
)�C���)�#��*;�<�H��/��4�h��D�Dr,c�l�t|�}t|tjj	|d��S)Nr})rWr�r�r�r�)r��env_keys  r+r�r�1s(��+�C�0�G�(��b�j�j�n�n�W�b�.I�J�Jr,c�*�t||g�\}}||fSr]�r�r�arg�stdout�stderrs    r+r�r�6s ���W�c�N�+��V�V��F��r,c�,�t|d|g�\}}||fS)Nz--cmdr�r�s    r+r�r�;s#���W�g�s�3�4��V�V��F��r,c�n�t|||�}|syt|dz||�}tt|�||�S)zj
    guestinfo returns the guestinfo value for the provided key, decoding
    the value when required
    Nr�)�guestinfo_get_valuer�rX)r�rrr�r�s     r+rr@s@��
�c�7�J�
7�C���"�3��#4�g�z�J�H��(��-�x��=�=r,c��tjd|�	||dt|�z�\}}|tk(rtjd|�n|stj	d|�t||�S#t$rR}|jtk(rtjd|�ntjtd||�|�Yd}~yd}~wt$r#}tjtd||�|�d}~wwxYw)z:
    Returns a guestinfo value for the specified key.
    z"Getting guestinfo value for key %sz	info-get r�z(Failed to get guestinfo value for key %sz,Failed to get guestinfo value for key %s: %sNzCUnexpected error while trying to get guestinfo value for key %s: %s)r=r>rX�NOVALr�r�rr�r	r�r�)r�rrr�r�r�s      r+r�r�Ls����I�I�2�C�8�!�%��[�#9�#�#>�>�
�����U�?��I�I�1�3�7���I�I�@�#�F�,�S�&�9�9�� ���<�<�5� ��I�I�1�3�7�

�K�K��>���	
��K�
8�,��������
-���	
�����s%�AA4�4	C9�=AC
�
C9�C4�4C9c�$�|dk(rd}tjd||�	||dt|��d|���y#t$r'}t	j
td|||�Yd}~yd}~wt$rt	j
td||�YywxYw)	z|
    Sets a guestinfo value for the specified key. Set value to an empty string
    to clear an existing guestinfo key.
    r}� z$Setting guestinfo key=%s to value=%sz	info-set Tz.Failed to set guestinfo key=%s to value=%s: %sNzAUnexpected error while trying to set guestinfo key=%s to value=%s)r=r>rXrr	r�r�)r��valuerrr�s     r+r�r�xs���
��{����I�I�4�c�5�A�
���)?��)D�e�L�	
��� �

�	
����<����	
�	
� ���
�����
+���	
��
�s�9�	B�A$�$(B�Bc�Z�|syt|�ttfvr|g}|D]�}t|�}tjd|�t
|t||�stjd|�tjd|�t
|dzd||�r�ttjd|���y)z�
    guestinfo_redact_keys redacts guestinfo of all of the keys in the given
    list. each key will have its value set to "---". Since the value is valid
    YAML, cloud-init can still read it if it tries.
    Nzclearing %szfailed to clear %szclearing %s.encodingr�r}zfailed to clear %s.encoding)	�type�list�tuplerXr=r?r�r�r�)�keysrrr�rus     r+rzrz�s������D�z�$���&��v���	?��)�#�.�������)�"��)�7�J�
�
�I�I�*�H�5����'��2�"�3��#4�b�'�:�N��I�I�3�X�>�	?r,c���|siSt|t�r|S	tj|�S#tj
tf$rtj|�cYSwxYw)z�
    load first attempts to unmarshal the provided data as JSON, and if
    that fails then attempts to unmarshal the data as YAML. If data is
    None then a new dictionary is returned.
    )�
isinstance�dictr	�	load_json�json�JSONDecodeError�	TypeError�	load_yaml)r�s r+rBrB�sX����	��$�����$��~�~�d�#�#��� � �)�,�$��~�~�d�#�#�$�s�-�.A�Ac��|siSd}d|vr|d}|d=d}d|vr|d}|d=|r�t|tjj�r-tjd�dt
j|�i}n0tjd|�td||�}dt|�i}tjd|�||d<|S)	z_
    process_metadata processes metadata and loads the optional network
    configuration.
    Nraznetwork.encodingz#network data copied to 'config' keyrbznetwork data to be decoded %szmetadata.networkznetwork data %s)
r��collections�abc�Mappingr=r>�copy�deepcopyr�rB)r�ra�network_enc�dec_nets    r+rArA�s���
��	��G��D���y�/����O��K��T�!��-�.���#�$���g�{���6�6�7��I�I�;�<�����w�!7�8�G��I�I�5�w�?��/��g�F�G��+�G�4��G�	�	�	�#�W�-�!��Y���Kr,c�6�tj|t�S)zK
    Return a list of data sources that match this set of dependencies
    )r�list_from_depends�datasources)�dependss r+�get_datasource_listr�s���$�$�W�k�:�:r,c��d}d}tj�}|dD]}|ddk(s�|d}n|dD]}|ddk(s�|d}nd}d}tj�}||vrK||d}t|�dkDrtjd	||�nt|�dk(rd
|dvr|dd
}||vrK||d}t|�dkDrtjd||�nt|�dk(rd
|dvr|dd
}|�C|�A|D]<}||dD]/}	|	d
|k(s�t||d�dk(s�!||ddd
}�<�>|�C|�A|D]<}||dD]/}	|	d
|k(s�t||d�dk(s�!||ddd
}�<�>||fS)
aI
    Returns the default IPv4 and IPv6 addresses based on the device(s) used for
    the default route. Please note that None may be returned for either address
    family if that family has no default route or if there are multiple
    addresses associated with the device used by the default route for a given
    address.
    Nr�destination�0.0.0.0�ifacerz::/0�z,device %s has more than one ipv4 address: %s�iprz,device %s has more than one ipv6 address: %s)r�
route_info�netdev_infor�r=r>)
�ipv4_if�ipv6_if�routes�routerr�netdev�addrs�dev_name�addrs
          r+�get_default_ip_addrsr�s2���G��G�
�
�
�
!�F���������9�,��G�n�G�����������6�)��G�n�G����D��D�
�
 �
 �
"�F��&���w���'���u�:��>��I�I�>���
���Z�1�_���q��!1���8�D�>�D��&���w���'���u�:��>��I�I�>���
���Z�1�_���q��!1���8�D�>�D�
��D�L��	�H��x�(��0�
����:��%�#�f�X�.>�v�.F�*G�1�*L�!�(�+�F�3�A�6�t�<�D��
�	��|��(��	�H��x�(��0�
����:��%�#�f�X�.>�v�.F�*G�1�*L�!�(�+�F�3�A�6�t�<�D��
�	���:�r,c�&�|j�}|r|dk(rtj�}	tj|ddtj
dtj�}|D]}|ds�	|d}|S|S#tj$rY|SwxYw)zoGet fully qualified domain name from name.
    An empty argument is interpreted as meaning the local host.
    rNr�)�stripr	�get_hostname�socket�getaddrinfo�
SOCK_DGRAM�AI_CANONNAMEr�)�namerrs   r+�getfqdnr<s����:�:�<�D��4�9�$�� � �"��
��"�"��$��6�,�,�a��1D�1D�
���	�D��A�w��A�w����K�		��K���<�<�
���K�
�s�6A9�9B�Bc��tjtj|�}|xr)|jxs|j
xs|jS)zn
    Returns false if the address is loopback, link local or unspecified;
    otherwise true is returned.
    )r�maybe_get_address�	ipaddress�
ip_address�
is_link_local�is_loopback�is_unspecified)r�rs  r+�is_valid_ip_addrr#SsM��
� � ��!5�!5�s�;�D������E�d�.�.�E�$�2E�2E��r,rr.c��|jd�siS|jd�|jd�|jd�d�S)a�
    Takes a cloudinit.netinfo formatted address and converts to netifaces
    format, since this module was originally written with netifaces as the
    network introspection module.
    netifaces ipv4 format:
    {
      "broadcast": "10.15.255.255",
      "netmask": "255.240.0.0",
      "addr": "10.0.1.4"
    }
    cloudinit.netinfo ipv4 format:
    {
      "ip": "10.0.1.4",
      "mask": "255.240.0.0",
      "bcast": "10.15.255.255",
      "scope": "global",
    }
    r�bcast�mask)�	broadcast�netmaskr)r�)rs r+� convert_to_netifaces_ipv4_formatr)^sA��&�8�8�D�>��	��X�X�g�&��8�8�F�#�������r,c���|jd�siStj|jd��}|j�d|jj
��t
|j�d�S)a�
    Takes a cloudinit.netinfo formatted address and converts to netifaces
    format, since this module was originally written with netifaces as the
    network introspection module.
    netifaces ipv6 format:
    {
      "netmask": "ffff:ffff:ffff:ffff::/64",
      "addr": "2001:db8:abcd:1234::1"
    }
    cloudinit.netinfo ipv6 format:
    {
      "ip": "2001:db8:abcd:1234::1/64",
      "scope6": "global",
    }
    r�/)r(r)r�r�
IPv6Interfacer(ra�	prefixlenrir)rrs  r+� convert_to_netifaces_ipv6_formatr.zs^�� �8�8�D�>��	��"�"�4�8�8�D�>�2�D��l�l�^�1�T�\�\�%;�%;�$<�=��D�G�G���r,c�V�ddtj�tj�tj�d�ii}ttj��}|r||d<||d<||d<t�\}}|r	||t<|r	||t<|ddd}|ddd}|ddd	}tj�}|D�]\}g}	g}
||d
D]}|	jt|���||dD]}|
jt|���||jd�}|d
k(r�p|rm|	s|
ri|}
i}|	r.g}|	D]"}t|d�s�|j|��$||d
<|
r.g}|
D]"}t|d�s�|j|��$||d<|||
<|	r<|	D]7}|d}
t|
�s�tj |�}|d=|r||d<|||
<�9|
s��!|
D]7}|d}
t|
�s�tj |�}|d=|r||d<|||
<�9��_|S)zP
    Returns host information such as the host name and network interfaces.
    ra�
interfaces)�by-mac�by-ipv4�by-ipv6�hostnamezlocal-hostname�local_hostnamer1r2r3rr�hwaddrz00:00:00:00:00:00r�mac)r��OrderedDictrr	rrr�r�rr�appendr)r.r�r#r�r�)rSr4�default_ipv4�default_ipv6�by_mac�by_ipv4�by_ipv6�ifacesr�af_inet4�af_inet6rr7r�r��
af_inet4_vals�ip_info�
af_inet6_valss                  r+�
get_host_inforE�s���
	��%�1�1�3�&�2�2�4�&�2�2�4��
��I��t�(�(�*�+�H�� (�	�*��&.�	�"�#�&.�	�"�#�!5�!7��L�,�� ,�	�*��� ,�	�*��
�y�
!�,�
/��
9�F��	�"�<�0��;�G��	�"�<�0��;�G�
�
 �
 �
"�F��5#�������8�$�V�,�	D�D��O�O�<�T�B�C�	D��8�$�V�,�	D�D��O�O�<�T�B�C�	D��X��"�"�8�,���%�%���H���C��C�� "�
�'�2�G�+�G�F�O�<� �!�(�(��1�2�,��F��� "�
�'�2�G�+�G�F�O�<� �!�(�(��1�2�,��F���F�3�K��#�
#���f�o��'��,���m�m�G�,����K��!$�C��J�"����
#��#�
#���f�o��'��,���m�m�G�,����K��!$�C��J�"����
#�[5#�n�r,c���d}d}t|vr{|t}t|vr1|t}t|t�r|}nt	j
|�}t|vr1|t}t|t�r|}nt	j
|�}d\}}}|��t�}|jd�xsi}	|	jd�xsi}
|
jd�xsi}|
jd�xsi}|r|rt|�dkDnd}|sd}|r|rt|�dkDnd}|sd}|�.tjd||||�tjd	�|���tjd
�|S)NF)NFFrar0r2r3rz<waiting on network: wait4=%s, ready4=%s, wait6=%s, ready6=%srzwaiting on network complete)�WAIT_ON_NETWORK�WAIT_ON_NETWORK_IPV4r��boolr	�translate_bool�WAIT_ON_NETWORK_IPV6rEr�r�r=r>�time�sleep)
rC�wait_on_ipv4�wait_on_ipv6rN�wait_on_ipv4_val�wait_on_ipv6_valrS�
ipv4_ready�
ipv6_readyrar0r=r>s
             r+rNrN�sv���L��L��(�"�"�?�3���?�2�.�/C�D���*�D�1�/��#�2�2�3C�D���?�2�.�/C�D���*�D�1�/��#�2�2�3C�D��);�%�I�z�:�
�
�"�O�	��-�-�	�*�0�b���[�[��.�4�"�
��.�.��+�1�r���.�.��+�1�r���-4��W���)�%�J�� �	��-4��W���)�%�J�� �	����I�I�N�����
�
�J�J�q�M�;�
�>�I�I�+�,��r,c��	tj�ttdt
diddddiii}t
|�}tj||g�}ttj|��y#t$rY�fwxYw)z7
    Executed when this file is used as a program.
    TFrarb�dhcpN)r�setup_basic_loggingr�rGrHrKrNr	rP�printr�
json_dumps)rCrSs  r+�mainrY#s���
����!�	� �$� �%�
�	�H�v�t�n�-��H� ��)�I��!�!�8�Y�"7�8�H�	�-�
"�
"�8�
,�-���
��
�s�A1�1	A=�<A=�__main__)r})Ir�r�r�rr��loggingr�rrL�	cloudinitrrrrrrr	�$cloudinit.sources.helpers.vmware.imcr
�cloudinit.subprrr
rh�	getLoggerr�r=r�rr!r#rxryrr�r�r�rGrHrKrrr<r�r�rOr�rYrXrWr�r�r�r�rr�r�rzrBrA�DEP_FILESYSTEM�DEP_NETWORKr�rrrr#r�r)r.rErNrYr�r,r+�<module>rbs���������	�
��J�J�J�?�=�=�9���g����!����%��*����	��'���
� ��
�
�
�
�#������M�w�)�)�M�`�(�*�$N�,
���P�E�K�
�
�
	>�)�X(�V?�,$�"�H��.�.�0�1���.�.��0C�0C�D�E���;�?�D�.��4��D��8�4��D��2U�p5�p.�(�z���F�r,

Zerion Mini Shell 1.0