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

�

���f�2��b�dZddlZddlZddlZddlZddlmZddlZddlm	Z	m
Z
mZeje
�ZGd�de	j�ZGd�de�Zdd	�Zd
�Zd�Zdd�Zd
�Zd�Zd�Zd�Zd�ZGd�de�Zee	j:ffee	j:e	j<fffZd�Z d�Z!y)zZCloud-Init DataSource for OVF

This module provides a cloud-init datasource for OVF data.
�N)�minidom)�sources�subp�utilc�D�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
d��Zy	)
�
DataSourceOVF�OVFc���tjj||||�d|_tj
j
|jd�|_d|_i|_	d|_
d|_y)N�ovf)�/zfile://)r�
DataSource�__init__�seed�os�path�join�seed_dir�environment�cfg�supported_seed_starts�_network_config��self�sys_cfg�distro�pathss    �A/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceOVF.pyrzDataSourceOVF.__init__ s\�����#�#�D�'�6�5�A���	������U�^�^�U�;��
�������%5��"�#���c�d�tjj|�}|�d|j�d�S)Nz [seed=�])rr
�__str__r)r�roots  rr!zDataSourceOVF.__str__)s'���!�!�)�)�$�/��!%�t�y�y�1�1rc���g}i}d}d}ddi}t|jj�\}}|r\tjj|jj|�}t
|�\}}}	||_|j|�nddtfdtfg}
d}|
D]\}}|�}|s�n|r;t
|d�\}}}	||_d|vr|dr
|d|_|j|�t|�dk(ry	d
|vr�|d
r�|d
}
d	}|jD]}|
j|�s�|}n|stj!d|
|�y	t#j$|
d��\}}}}tj!d
|
�t#j&||g�}|j|
�t#j&||g�}dj|�|_||_||_||_	|_y)N��instance-idz	iid-dsovfzcom.vmware.guestInfo�isoT�network-configrF�seedfromz Seed from %s not supported by %s)�timeoutzUsing seeded cache data from %s�,)�get_ovf_envrrrrr�read_ovf_environmentr�append�transport_vmware_guestinfo�transport_iso9660r�lenr�
startswith�LOG�debugr�read_seeded�
mergemanydictr�metadata�userdata_raw�vendordata_rawr)r�found�md�ud�vd�defaults�seedfile�contentsrr�np�name�	transfuncr(�	seedfound�proto�md_seed�_s                  r�	_get_datazDataSourceOVF._get_data-s����
��
��
��
�;�
�� +�4�:�:�+>�+>�?���8���7�7�<�<��
�
� 3� 3�X�>�D�0��:�M�R��S�'�D���L�L���(�)C�D��)�*��B��D�#%�
���i�$�;����
�� 4�X�t� D�
��R��#+�� �#�r�)�b�1A�.B�+-�.>�+?�D�(����T�"��u�:��?������:���*�~�H��I��3�3�
���&�&�u�-� %�I��
���	�	�<�h��M��#'�#3�#3�H�d�#K� �W�b�"�a��I�I�7��B��#�#�R��M�2�B��L�L��"��
�
��X��
/���H�H�U�O��	���
���� ������rc� �d|jzS)Nzovf (%s))r�rs r�_get_subplatformzDataSourceOVF._get_subplatformos���D�I�I�%�%rc�j�d|jvrgS|jd}t|t�r|S|gS)N�public-keys)r6�
isinstance�list)r�pkss  r�get_public_ssh_keysz!DataSourceOVF.get_public_ssh_keysrs7����
�
�-��I��m�m�M�*���c�D�"��J��5�Lrc��|jS�N)rrIs r�get_config_objzDataSourceOVF.get_config_obj~s���x�x�rc��|jSrR)rrIs r�network_configzDataSourceOVF.network_config�s���#�#�#rN)�__name__�
__module__�__qualname__�dsnamerr!rGrJrPrS�propertyrU�rrrrs;��
�F�$�2�@�D&����$��$rrc��eZdZd�Zy)�DataSourceOVFNetc��tj||||�tjj	|j
d�|_d|_y)Nzovf-net)zhttp://zhttps://)rrrrrrrrs    rrzDataSourceOVFNet.__init__�s8�����t�W�f�e�<������U�^�^�Y�?��
�%<��"rN)rVrWrXrr[rrr]r]�s��=rr]c��t|�}i}i}d}dg}gd�}dg}|j�D]�\}	}
|	dk(rd}	|	|vr|
||	<�|	|vr|
||	<�!|	|vrD|rB	tj|
j	��}t|�j
d�||	<�i|	dk(s�o	tj|
j	��}��|||fS#t$rtjd�Y��wxYw#t$r|
j	�}Y��wxYw)	N�password)r(�local-hostnamerLr%r'�hostnamera�networkz%Ignore network-config in wrong formatz	user-data)
�get_properties�items�base64�	b64decode�encode�safeload_yaml_or_dict�get�	Exceptionr2r3)r?�read_network�propsr:rr;�	cfg_props�md_props�
network_props�prop�valrUs            rr,r,�s$���8�$�E�	�B�
�C�	
�B���I�K�H�%�&�M��[�[�]�"�	��c��:��#�D��8���B�t�H�
�Y�
��C��I�
�]�
"�|�
C�!'�!1�!1�#�*�*�,�!?��0��@�D�D�Y�O��4���[�
 �
"��%�%�c�j�j�l�3��"�$
��C�=����
C��	�	�A�B�
C��
�
"��Z�Z�\��
"�s%�AC�#C*�C'�&C'�*D�Dc� �d}|D]]}tjj||�}tjj|�s�C	t	j
|�}||fcSy#t$rt	jtd|�Y��wxYw)N)zovf-env.xmlzovf_env.xmlzOVF_ENV.XMLzOVF-ENV.XMLzFailed loading ovf file %s)NF)	rrr�isfiler�load_text_filerk�logexcr2)�dirname�	env_names�fname�full_fnr?s     rr+r+�s���L�I��H���'�'�,�,�w��.��
�7�7�>�>�'�"�
H��.�.�w�7���x�(�(�H����
H����C�!=�w�G�
H�s�	A&�&$B
�B
c���|syt|t�std|z��tjj|�}|j
d�r|jd�d}|j
d�r|jd�d}n|jd�dkDry|syd}tjjd|�}tj|�}|j|�d	uS)
z�Test if devname matches known list of devices which may contain iso9660
       filesystems.

    Be helpful in accepting either knames (with no leading /dev/) or full path
    names, but do not allow paths outside of /dev/, like /dev/foo/bar/xxx.
    Fz Unexpected input for devname: %sz/dev/���rrz^(sr[0-9]+|hd[a-z]|xvd.*)�CLOUD_INIT_CDROM_DEV_REGEXN)rM�str�
ValueErrorrr�normpathr1�	partition�split�count�environrj�re�compile�match)�devname�
default_regex�
devname_regex�cdmatchs    r�maybe_cdrom_devicer��s�����
���
%��;�g�E�F�F��g�g���w�'�G����'�"��#�#�G�,�R�0�����#���-�-��$�R�(��	���s�	�a�	����1�M��J�J�N�N�#?��O�M��j�j��'�G��=�=��!��-�-rc��tj�}|j�D]9\}}|d}|dk7r|r�t|�s�|d}t	|�\}}|dus�7|cS|rd}nd}tj
|rd|znd�D�cgc]}t|�r|��}	}|	D]*}	tj|t|��\}}|dus�(|cSycc}w#tj$rtjd|�Y�^wxYw)N�fstype�iso9660�
mountpointFzTYPE=%s)�mtypez%s not mountable as iso9660)
r�mountsrer�r+�find_devs_with�mount_cb�MountFailedErrorr2r3)
�require_isor��dev�infor��mp�_fnamer?r��devss
          rr/r/�s%��
�[�[�]�F��\�\�^�	�	��T��h����Y��;��!�#�&��
�,�
��(��_�����5� ��O�	������
�&�&�E�y�5�'8�t�L����c�"�	��D��
���	�!%���s�K�u�!M��V�X�
�5� ��O�������$�$�	��I�I�3�S�9��	�s�C�"C�)C=�<C=c�D�||g}tj|�\}}|||fSrR�r��rpctool�arg�cmd�stdout�stderrs     r�exec_vmware_rpctoolr�
s*���C�.�C��y�y��~��V�V���� � rc�F�|d|g}tj|�\}}|||fS)Nz--cmdr�r�s     r�
exec_vmtoolsdr�s-���G�S�
!�C��y�y��~��V�V���� � rc��d\}}tjd�}tjd�}|r|t}}tj	d|�|r |s|t
}}tj	d|�|stj	d�yd�}	|||�S#tj$r�}|r%||k(r tjtd|�Yd}~y|stjd	�Yd}~y	tjd
�||t
�cYd}~S#tj$r%}tjtd|�Yd}~nd}~wwxYwYd}~yd}~wwxYw)N)NN�vmtoolsdzvmware-rpctoolzdiscovered vmware-rpctool: %szdiscovered vmtoolsd: %szno rpctool discoveredc��tjd|�	||d�\}}}|r|Stjd|�y#tj$r7}|j
dk7r!tj
d||j
�|�d}~wwxYw)Nzquery guestinfo.ovfEnv with %szinfo-get guestinfo.ovfEnvz!cmd %s exited 0 with empty stdout�z%s exited with code %d)r2r�r3r�ProcessExecutionError�	exit_code�warning)r��
rpctool_fnr�r�rF�errors      r�query_guestinfoz3transport_vmware_guestinfo.<locals>.query_guestinfo-s�����1�7�;�		�'��1L�M�N�C�����
��I�I�9�3�?����)�)�	����!�#����4�g�u���O��K��	�s�A�A�B
�2B�B
z+vmtoolsd failed to get guestinfo.ovfEnv: %sz$vmtoolsd fallback option not presentzfallback to vmtoolsd)
r�whichr�r2r3r�r�rrvr�)r�r�r��vmware_rpctoolr�r�s      rr.r.s;��$��G�Z��z�z�*�%�H��Z�Z� 0�1�N��,�.A����	�	�1�>�B���"*�M�Z�G��	�	�+�X�6���	�	�)�*�����w�
�3�3���%�%����8�+��K�K��B�E�
����H�H�;�<��	��H�H�+�,�"�8�]�;�;���)�)�	��K�K��B�E�
�
��	��
���5�sH�B�E�*"E�E�.!D�E�E
�(E�E�E
�
E�Ec��g}|j�s|S|jD]}||�s�|j|��|SrR)�
hasChildNodes�
childNodesr-)�node�filter_func�ret�childs    r�
find_childr�[sF��
�C������
�������u���J�J�u����Jrc��tj|�}|jjdk7rt	d��|jj�st	d��d}t
|jd��}t|�dk(rt	d��i}t
|dd��}|D]S}|jj|d	�j}|jj|d
�j}|||<�U|S)N�EnvironmentzNo Environment NodezNo Child Nodesz)http://schemas.dmtf.org/ovf/environment/1c� �|jdk(S)N�PropertySection��	localName��ns r�<lambda>z get_properties.<locals>.<lambda>rs��q�{�{�6G�'G�rrzNo 'PropertySection'sc� �|jdk(S)N�Propertyr�r�s rr�z get_properties.<locals>.<lambda>zs��A�K�K�:�$=�r�key�value)r�parseString�documentElementr��XmlErrorr�r�r0�
attributes�getNamedItemNSr�)	r?�dom�envNsURI�propSectionsrm�	propElems�elemr�rrs	         rrdrdes���
�
�
�h�
'�C�
���$�$�
�5��,�-�-����,�,�.��'�(�(�:�H�����G��L��<��A���.�/�/��E���Q��=��I�����o�o�,�,�X�u�=�C�C���o�o�,�,�X�w�?�E�E����c�
��
�Lrc��eZdZy)r�N)rVrWrXr[rrr�r��s��rr�c�6�tj|t�SrR)r�list_from_depends�datasources)�dependss r�get_datasource_listr��s���$�$�W�k�:�:rc�4�|siStj|�S)z�
    The meta data could be JSON or YAML. Since YAML is a strict superset of
    JSON, we will unmarshal the data as YAML. If data is None then a new
    dictionary is returned.
    )�yaml�	safe_load)�datas rriri�s����	��>�>�$��r)F)T)"�__doc__rf�loggingrr��xml.domrr��	cloudinitrrr�	getLoggerrVr2r
rr]r,r+r�r/r�r�r.r�rdrkr��DEP_FILESYSTEM�DEP_NETWORKr�r�rir[rr�<module>r�s����
��	�	���)�)��g����!��f$�G�&�&�f$�R=�}�=��>
�$.�R#�L!�!�B�J��@	�y�	��W�+�+�-�.���.�.��0C�0C�D�E���;� r

Zerion Mini Shell 1.0