%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�f�?���ddlZddlZddlZddlmZmZmZddlmZddl	m	Z	ddl
mZmZm
Z
ddlmZmZmZmZej&e�ZGd�de�ZGd	�d
�ZGd�d�ZGd
�d�Zd�ZGd�d�ZGd�d�ZGd�d�ZGd�d�ZGd�dej@�Z!Gd�de�Z"y)�N)�
NoOptionError�NoSectionError�RawConfigParser)�StringIO)�time)�persistence�
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 r3s  rr!zFileLock.__init__0s	����rc�N�dtj|��d|j�d�S)N�<z using file �>)r	�obj_namer3rs r�__str__zFileLock.__str__3s��'1�':�':�4�'@�$�'�'�J�JrN)rrrr!r8rrrr1r1/s
���Krr1c�&�|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 rBs  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=rF�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*rI�os�getpidrr
�
write_filerKrLrMrNr1)r r=rFrO�contentss     rrDzFileSemaphores._acquireSs����<�<��d�#���>�>�$��-��!#����d�f�5��	��O�O�H�h�/���!�!����!�	��K�K��?��J��	�s�	A*�**B�Bc��|r	|tk(ryt|�}|j||�}tjj|�Sr()rr>rIrR�path�exists)r r=rF�cnamerOs     rr*zFileSemaphores.has_runcs>���t�z�)���t�$���>�>�%��.���w�w�~�~�h�'�'rc��|j}|r	|tk(r tjj	||�Stjj	||�d|���S)N�.)rBr
rRrW�join)r r=rFrBs    rrIzFileSemaphores._get_pathmsD���=�=���t�|�+��7�7�<�<��$�/�/��7�7�<�<��T�4�*@�A�ArNr-)rrrr!r.r/r&r,rDr*rIrrrr@r@;s6��!��������"� (�Brr@c� �eZdZd�Zd�Zdd�Zy)�Runnersc� �||_i|_yr)�paths�sems)r r`s  rr!zRunners.__init__vs����
���	rc� �|tk(s|syd}|tk(r|jjd�}n$|tk(r|jjd�}|sy||jvrt|�|j|<|j|S)N�sem)rr
r`�	get_ipathr�	get_cpathrar@)r rFrBs   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)	rfrr*rN�debugr&r�
isinstance�dict)	r r=�functor�argsrFrGrc�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!rfrorrrr^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 r`�
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)	rt�get_config_objrirj�appendrEr
rMrN)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)	rrR�environrr
�	read_confrErMrN)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)rsrwr�
get_ipath_currRrW�isfiler
r��PermissionErrorrNrhrErM)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)
rurr
r�rErMrN�extendr�r�r�rv�
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)rxr�rs r�cfgzConfigMerger.cfgs&���9�9�����(�D�I��y�y�r)NNNNT)rrrr!r�r�r�rjr��propertyr�rrrrqrq�sH�������
� 
���@(�4�(�0���rrqc�8�eZdZd�Zd�Zd�Zd�Zd	d�Zd�Zd�Z	y)
�ContentHandlersc� �i|_g|_yr)�
registered�initializedrs 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��itemsrs 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�|_tj
j
|jd�|_tj
j
|jd�|_tj
j
|jd�|_	|jdd	�}tj
j
|d
�|_
idd�dd
�dd�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/��|_||_y)0N�	cloud_dirz/var/lib/cloud�run_dirz/run/cloud-init�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�scriptsrc�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�rRrWr\�
instance_link�
boot_finished�seed_dir�template_tpl�lookupsry)r r��ds�template_dirs    rr!zPaths.__init__2s�����	�'�m�m�K�9I�J���%�M�M�)�5F�G���"$�'�'�,�,�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�ryr�r�)r r�s  r�	_unpicklezPaths._unpicklecs����t�Y�'�!��)�)������g�
�L��$�,�,�.�,@�D�L�L��)�$�D�L�L�8�/�
�L�L�)�
�#�$�,�,�6�-�
�L�L�'�
��D�L�L�0�.?�D�L�L�*�+�1rc�:�|j|j|�Sr)rIr��r r=s  rr�zPaths.get_ipath_cur|s���~�~�d�0�0�$�7�7rc�:�|j|j|�Sr)rIr�r�s  rrezPaths.get_cpath�s���~�~�d�n�n�d�3�3rc�|�|jsy|jj�}|�yt|�jtj
d�}tjj|jd|�}|jj|�}|r tjj||�}|S)Nr;�	instances)ry�get_instance_id�strr<rR�seprWr\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�rN�warning)r r=r�s   rrdzPaths.get_ipath�s.������%����K�K�2�
���Lr�basec�d�|�|Stjj||j|�Sr)rRrWr\r�)r r�r=s   rrIzPaths._get_path�s*���<��K��w�w�|�|�D�$�,�,�t�"4�5�5rc�:�|j|j|�Sr)rIr�r�s  r�get_runpathzPaths.get_runpath�s���~�~�d�l�l�D�1�1rr)rrr�_ci_pkl_versionrjr!�intr�r�rer�rdr�rIr�rrrr�r�/sO���O�/�$�/�b@��@��@�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�rQ)r�write�flush�getvaluer\)r �headerrU�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.�loggingrR�configparserrrr�iorr�	cloudinitrr	r
�cloudinit.settingsrrr
r�	getLoggerrrNrErrrr1r>r@r^rqr��CloudInitPickleMixinr�rrrr�<module>r(s�����	�G�G���3�3�O�O��g����!��	�)�	�	�	���K�K�"�7B�7B�t*'�*'�Zg�g�T -� -�Fx2�K�,�,�x2�J0�_�0r

Zerion Mini Shell 1.0