%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Create Path :
Current File : //proc/self/root/lib/python3/dist-packages/cloudinit/__pycache__/helpers.cpython-312.pyc

�

���fu@���ddlZddlZddlZddlmZmZmZddlmZddl	m	Z	ddl
mZmZm
Z
mZddlmZmZmZmZej(e�ZGd�de�ZGd	�d
�ZGd�d�ZGd
�d�Zd�ZGd�d�ZGd�d�ZGd�d�ZGd�d�Z Gd�dejB�Z"Gd�de�Z#y)�N)�
NoOptionError�NoSectionError�RawConfigParser)�StringIO)�time)�persistence�settings�
type_utils�util)�CFG_ENV_NAME�
PER_ALWAYS�PER_INSTANCE�PER_ONCEc��eZdZy)�LockFailureN��__name__�
__module__�__qualname__���3/usr/lib/python3/dist-packages/cloudinit/helpers.pyrr���rrc��eZdZy)�	DummyLockNrrrrrrrrrc�D�eZdZd�Zej
dd��Zd�Zd�Zy)�DummySemaphoresc��y�Nr��selfs r�__init__zDummySemaphores.__init__!s��rc#�$K�t���y�wr)r)r!�_name�_freq�_clear_on_fails    r�lockzDummySemaphores.lock$s�����k��s�c��y�NFr�r!r$r%s   r�has_runzDummySemaphores.has_run(s��rc��y)NTrr*s   r�clearzDummySemaphores.clear+s��rN�F)	rrrr"�
contextlib�contextmanagerr'r+r-rrrrr s+��
��������rrc��eZdZd�Zd�Zy)�FileLockc��||_yr)�fn)r!r4s  rr"zFileLock.__init__0s	����rc�N�dtj|��d|j�d�S)N�<z using file �>)r
�obj_namer4r s r�__str__zFileLock.__str__3s��'1�':�':�4�'@�$�'�'�J�JrN)rrrr"r9rrrr2r2/s
���Krr2c�&�|jdd�S)N�-�_)�replace)�names r�canon_sem_namer?7s���<�<��S�!�!rc�P�eZdZd�Zej
dd��Zd�Zd�Zd�Z	d�Z
y)	�FileSemaphoresc��||_yr)�sem_path)r!rCs  rr"zFileSemaphores.__init__<s	�� ��
rc#�K�t|�}	|j||���y#t$r|r|j||��wxYw�wr)r?�_acquire�	Exceptionr-)r!r>�freq�
clear_on_fails    rr'zFileSemaphores.lock?sH�����d�#��	��-�-��d�+�+���	���
�
�4��&��	�s�A�$�A�A�Ac���t|�}|j||�}	tj|�y#tt
f$rtjtd|�YywxYw)NzFailed deleting semaphore %sFT)r?�	_get_pathr�del_file�IOError�OSError�logexc�LOG)r!r>rG�sem_files    rr-zFileSemaphores.clearIs\���d�#���>�>�$��-��	��M�M�(�#�����!�	��K�K��;�X�F��	�s�5�*A"�!A"c�4�|j||�ry|j||�}tj��dt	��d�}	tj||�t|�S#ttf$rtjtd|�YywxYw)Nz: �
z Failed writing semaphore file %s)r+rJ�os�getpidrr�
write_filerLrMrNrOr2)r!r>rGrP�contentss     rrEzFileSemaphores._acquireSs����<�<��d�#���>�>�$��-��!#����d�f�5��	��O�O�H�h�/���!�!����!�	��K�K��?��J��	�s�	A*�**B�Bc��|r	|tk(ryt|�}|j||�}tjj|�Sr))r
r?rJrS�path�exists)r!r>rG�cnamerPs     rr+zFileSemaphores.has_runcs>���t�z�)���t�$���>�>�%��.���w�w�~�~�h�'�'rc��|j}|r	|tk(r tjj	||�Stjj	||�d|���S)N�.)rCrrSrX�join)r!r>rGrCs    rrJzFileSemaphores._get_pathmsD���=�=���t�|�+��7�7�<�<��$�/�/��7�7�<�<��T�4�*@�A�ArNr.)rrrr"r/r0r'r-rEr+rJrrrrArA;s6��!��������"� (�BrrAc� �eZdZd�Zd�Zdd�Zy)�Runnersc� �||_i|_yr)�paths�sems)r!ras  rr"zRunners.__init__vs����
���	rc� �|tk(s|syd}|tk(r|jjd�}n$|tk(r|jjd�}|sy||jvrt|�|j|<|j|S)N�sem)r
rra�	get_ipathr�	get_cpathrbrA)r!rGrCs   r�_get_semzRunners._get_semzs����:��T�����<���z�z�+�+�E�2�H�
�X�
��z�z�+�+�E�2�H����4�9�9�$�"0��":�D�I�I�h���y�y��"�"rNc�|�|j|�}|s
t�}|sg}|j||�rtj	d||�y|j|||�5}|st
d|z��tj	d||�t|t�r	|di|��}n||�}d|fcddd�S#1swYyxYw)Nz%s already ran (freq=%s))FNzFailed to acquire lock for %szRunning %s using lock (%s)Tr)	rgrr+rO�debugr'r�
isinstance�dict)	r!r>�functor�argsrGrHrd�lk�resultss	         r�runzRunners.run�s����m�m�D�!���!�#�C���D��;�;�t�T�"��I�I�0�$��=� �
�X�X�d�D�-�
0�		'�B��!�"A�D�"H�I�I��	�	�6��b�A��d�T�+�%�o��o�G�%�t�n�G��g��		'�		'�		'�s
�A	B2�2B;r))rrrr"rgrprrrr_r_us���#�&'rr_c�L�eZdZ					d	d�Zd�Zd�Zd�Zdefd�Ze	d��Z
y)
�ConfigMergerNc�X�||_||_||_||_||_d|_yr)�_paths�_ds�_fns�	_base_cfg�_include_vendor�_cfg)r!ra�
datasource�additional_fns�base_cfg�include_vendors      rr"zConfigMerger.__init__�s/��������"��	�!���-�����	rc��g}|jr@	|jj�}|r!t|t�r|j	|�|S|S#t
$r)t
jtd|j�Y|SwxYw)Nz2Failed loading of datasource config object from %s)	ru�get_config_objrjrk�appendrFrrNrO)r!�d_cfgs�ds_cfgs   r�_get_datasource_configsz$ConfigMerger._get_datasource_configs�sy�����8�8�	
����0�0�2���j��$�8��M�M�&�)��
�v�
��
�
�����H��H�H��
�
�

�s�=A�.B�Bc��g}ttjvr>tjt}	|jt	j
|��|S|S#t$rt	jtd|�Y|SwxYw)Nz%Failed loading of env. config from %s)	rrS�environr�r�	read_confrFrNrO)r!�e_cfgs�e_fns   r�_get_env_configszConfigMerger._get_env_configs�sp�����2�:�:�%��:�:�l�+�D�
P��
�
�d�n�n�T�2�3��
�v�
���
P����C�!H�$�O��
�
P�s�$A�$B�Bc���g}|js|Sdg}|jr"|jd�|jd�|D]e}|jj|�}|s�!tj
j
|�s�A	|jtj|���g|S#t$rtjd|�Y��t$rtjtd|�Y��wxYw)N�cloud_config�vendor2_cloud_config�vendor_cloud_configz5Skipped loading cloud-config from %s due to non-root.z&Failed loading of cloud-config from %s)rtrxr��
get_ipath_currSrX�isfilerr��PermissionErrorrOrirFrN)r!�i_cfgs�cc_paths�cc_p�cc_fns     r�_get_instance_configsz"ConfigMerger._get_instance_configs�s������{�{��M�"�#�����
�O�O�2�3��O�O�1�2��	�D��K�K�-�-�d�3�E��������.���M�M�$�.�.��"7�8�		��
��'���I�I�%���
!���K�K��E�u���s�$B.�.C5�#C5�4C5�returnc��g}|jr6|jD]'}	|jtj|���)|j|j��|j|j��|j|j��|jr|j|j�tj|�S#t$rtj
td|�Y��wxYw)Nz'Failed loading of configuration from %s)
rvr�rr�rFrNrO�extendr�r�r�rw�
mergemanydict)r!�cfgs�c_fns   r�	_read_cfgzConfigMerger._read_cfg�s������9�9��	�	�
����K�K����t� 4�5�
�	
���D�)�)�+�,����D�.�.�0�1����D�0�0�2�3��>�>��K�K����'��!�!�$�'�'��!���K�K��F����s�$C�$D�Dc�\�|j�|j�|_|jSr)ryr�r s r�cfgzConfigMerger.cfgs&���9�9�����(�D�I��y�y�r)NNNNT)rrrr"r�r�r�rkr��propertyr�rrrrrrr�sH�������
� 
���@(�4�(�0���rrrc�8�eZdZd�Zd�Zd�Zd�Zd	d�Zd�Zd�Z	y)
�ContentHandlersc� �i|_g|_yr)�
registered�initializedr s rr"zContentHandlers.__init__
s�������rc�$�|j|�Sr)�
is_registered)r!�items  r�__contains__zContentHandlers.__contains__s���!�!�$�'�'rc�$�|j|�Sr)�_get_handler)r!�keys  r�__getitem__zContentHandlers.__getitem__s��� � ��%�%rc��||jvSr�r��r!�content_types  rr�zContentHandlers.is_registereds���t���.�.rc�4�t�}|j�D]9}|r|j|��|j|�r�)|j|��;|D]}||j|<�|r)||j
vr|j
j
|�|Sr)�set�
list_types�addr�r�r�r�)r!�modr��	overwrite�types�ts      r�registerzContentHandlers.registers���������!�	!�A���	�	�!���)�)�!�,��I�I�a�L�	!��	%�A�!$�D�O�O�A��	%��3�d�&6�&6�6����#�#�C�(��rc� �|j|Srr�r�s  rr�zContentHandlers._get_handler(s�����|�,�,rc�H�t|jj��Sr)�listr��itemsr s rr�zContentHandlers.items+s���D�O�O�)�)�+�,�,rN)FT)
rrrr"r�r�r�r�r�r�rrrr�r�s%���(�&�/��-�-rr�c�d�eZdZdZddefd�Zdeddfd�Zdd�Zdd	�Z	dd
�Z
dd�Zddefd
�Z
dd�Zy)�Paths�N�	path_cfgsc	���||_|jdd�|_|jdd�|_|jdtj
�|_tjj|jd�|_
tjj|jd�|_tjj|jd�|_|jd	d
�}tjj|d�|_
idd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d �d!d"�d#d$�d%d&�d'd(�d)d*d+d,d-d.d/d0��|_||_y)1N�	cloud_dirz/var/lib/cloud�docs_dirz/usr/share/doc/cloud-init/�run_dir�instancez
boot-finished�seed�
templates_dirz/etc/cloud/templates/z%s.tmpl�	boothooksr�zcloud-config.txt�data�handlers�
instance_data�instance-data.json�instance_data_sensitive�instance-data-sensitive.json�combined_cloud_config�combined-cloud-config.json�network_configznetwork-config.json�instance_idz.instance-id�manual_clean_markerzmanual-clean�obj_pklzobj.pkl�scriptsrd�userdatazuser-data.txt.i�userdata_rawz
user-data.txt�
vendordatazvendor-data.txt.i�vendordata2zvendor-data2.txt.izvendor-data2.txtzvendor-data.txtzvendor2-cloud-config.txtzvendor-cloud-config.txtzscripts/vendor�warnings�hotplug.enabled)�vendordata2_raw�vendordata_rawr�r��vendor_scriptsr�r�)r��getr�r�r	�DEFAULT_RUN_DIRr�rSrXr]�
instance_link�
boot_finished�seed_dir�template_tpl�lookupsrz)r!r��ds�template_dirs    rr"zPaths.__init__2s�����	�'�m�m�K�9I�J���&�]�]��4�
��
�&�M�M�)�X�5M�5M�N���"$�'�'�,�,�t�~�~�z�"J���"$�'�'�,�,�����#
��� �W�W�\�\�$�.�.�&�A��
�%�M�M��4�
��"$�����l�I�!F���
���
��.�
�
�F�
�
�
�	
�
�1�
�
&�'E�
�
$�%A�
�
�3�
�
�>�
�
"�>�
� 
�y�!
�"
�y�#
�$
�5�%
�&
�)�'
�(
�O�)
�*
�-�+
�,
�/�-
�. 2�/�$>�#<�.�"�0�;
���@��r�ci_pkl_versionr�c�f�t|d�s0t|j|j��j|_d|j
vrd|j
d<d|j
vrd|j
d<d|j
vrd|j
d<d	|j
vrd	|j
d	<y
y
)z(Perform deserialization fixes for Paths.r�)r�r�r�r�r�r�r�r�r�N)�hasattrr�r�rzr�r�)r!r�s  r�	_unpicklezPaths._unpicklefs����t�Y�'�!��)�)������g�
�L��$�,�,�.�,@�D�L�L��)�$�D�L�L�8�.�
�L�L�2�3�#�$�,�,�6�,�
�L�L�0�1��D�L�L�0�.?�D�L�L�*�+�1rc�:�|j|j|�Sr)rJr��r!r>s  rr�zPaths.get_ipath_curs���~�~�d�0�0�$�7�7rc�:�|j|j|�Sr)rJr�r�s  rrfzPaths.get_cpath�s���~�~�d�n�n�d�3�3rc�|�|jsy|jj�}|�yt|�jtj
d�}tjj|jd|�}|jj|�}|r tjj||�}|S)Nr<�	instances)rz�get_instance_id�strr=rS�seprXr]r�r�r�)r!r>�iid�
path_safe_iid�ipath�add_ons      r�
_get_ipathzPaths._get_ipath�s��������o�o�-�-�/���;���C��(�(�����5�
������T�^�^�[�-�H�����!�!�$�'����G�G�L�L���/�E��rc�X�|j|�}|stjd�y|S)Nz?No per instance data available, is there an datasource/iid set?)r�rO�warning)r!r>r�s   rrezPaths.get_ipath�s.������%����K�K�2�
���Lr�basec�d�|�|Stjj||j|�Sr)rSrXr]r�)r!r�r>s   rrJzPaths._get_path�s*���<��K��w�w�|�|�D�$�,�,�t�"4�5�5rc�:�|j|j|�Sr)rJr�r�s  r�get_runpathzPaths.get_runpath�s���~�~�d�l�l�D�1�1rr)rrr�_ci_pkl_versionrkr"�intr�r�rfr�rer�rJr�rrrr�r�/sO���O�2�$�2�h@��@��@�28�
4�
� 	�6�c�6�
2rr�c�J�eZdZdZdZdZdZd�Zdd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
y)
�DefaultingConfigParserrgFNc��|j}	tj|||�}|S#t$rY|St$rY|SwxYwr)�DEF_BASErr�rr�r!�section�option�values    rr�zDefaultingConfigParser.get�sX���
�
��	�#�'�'��g�v�>�E�
���	�	�����	����	�s�'�	?�?�?c��|j|�s$|j�dk7r|j|�tj||||�y)N�default)�has_section�lower�add_sectionrr�rs    rr�zDefaultingConfigParser.set�s?������(�W�]�]�_�	�-I����W�%����D�'�6�5�9rc�X�|j||�rtj|||�yyr)�
has_optionr�
remove_option�r!rrs   rrz$DefaultingConfigParser.remove_option�s'���?�?�7�F�+��)�)�$���@�,rc�l�|j||�s|jStj|||�Sr)r�DEF_BOOLEANr�
getbooleanrs   rrz!DefaultingConfigParser.getboolean�s1�����w��/��#�#�#��)�)�$���@�@rc�l�|j||�s|jStj|||�Sr)r�	DEF_FLOATr�getfloatrs   rrzDefaultingConfigParser.getfloat�s/�����w��/��>�>�!��'�'��g�v�>�>rc�l�|j||�s|jStj|||�Sr)r�DEF_INTr�getintrs   rrzDefaultingConfigParser.getint�s/�����w��/��<�<���%�%�d�G�V�<�<rc��d}t�}|j|�|j�|j�}|rdj	||dg�}|S)N�rR)r�write�flush�getvaluer])r!�headerrV�outputstreams    r�	stringifyz DefaultingConfigParser.stringify�sQ�����z���
�
�<� ������(�(�*����y�y�&�(�B�!7�8�H��rr)rrrrrrrr�r�rrrrr#rrrrr�s;���G��I��K��H��:�
A�A�
?�
=�
rr)$r/�loggingrS�configparserrrr�iorr�	cloudinitrr	r
r�cloudinit.settingsrr
rr�	getLoggerrrOrFrrrr2r?rAr_rrr��CloudInitPickleMixinr�rrrr�<module>r+s�����	�G�G���=�=�O�O��g����!��	�)�	�	�	���K�K�"�7B�7B�t*'�*'�Zg�g�T -� -�F{2�K�,�,�{2�P0�_�0r

Zerion Mini Shell 1.0