%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/cloudinit/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/cloudinit/__pycache__/socket.cpython-312.pyc |
� ���f; � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ej e� Zde fd�Z G d� d� Zy) z#A module for common socket helpers.� N)�suppress)�DEFAULT_RUN_DIR�messagec � � t j j dd� }|sy|d dk( r|j ddd� n|d dk7 rt d � �t j t j t j t j z � 5 }t j d t | � � |j |� |j | j d� � ddd� y# 1 sw Y yxY w)z[Send a sd_notify message. :param message: sd-notify message (must be valid ascii) � NOTIFY_SOCKET� Nr �@� � �/zUnsupported socket typezSending sd_notify(%s)�ascii)�os�environ�get�replace�OSError�socket�AF_UNIX� SOCK_DGRAM�SOCK_CLOEXEC�LOG�info�str�connect�sendall�encode)r �socket_path�socks �2/usr/lib/python3/dist-packages/cloudinit/socket.py� sd_notifyr s� � � �*�*�.�.��"�5�K��� �Q��3� ����C��q�)� �Q��3� ��/�0�0� �������)�)�F�,?�,?�?� � .� ����(�#�g�,�7����[�!����W�^�^�G�,�-�.� .� .�s �AC0�0C9c �4 � e Zd ZdZdefd�Zdefd�Zd� Zd� Zy) � SocketSyncz<A two way synchronization protocol over Unix domain sockets.�namesc �0 � d| _ d| _ d| _ d| _ d| _ |D �ci c]F }|t j t j t j t j z � ��H c}| _ t j t � d�dd�� | j j � D ]O \ }}t � d|� d �}t t � 5 t j |� d d d � |j# |� �Q y c c}w # 1 sw Y �"xY w)an Initialize a synchronization context. 1) Ensure that the socket directory exists. 2) Bind a socket for each stage. Binding the sockets on initialization allows receipt of stage "start" notifications prior to the cloud-init stage being ready to start. :param names: stage names, used as a unique identifiers r r Fz/sharei� T)�mode�exist_ok�/share/z.sockN)�stage�remote�first_exception�systemd_exit_code�experienced_any_errorr r r r �socketsr �makedirsr �itemsr �FileNotFoundError�remove�bind)�selfr# �namer r s r �__init__zSocketSync.__init__- s� � � �� ����!���!"���%*��"� � � � �&�-�-����� 1� 1�F�4G�4G� G�� � ��� ����'�v�.�U�T�J��,�,�,�,�.� #�J�D�$�,�-�W�T�F�%�@�K��+�,� '�� � �+�&� '��I�I�k�"� #�� � '� '�s �AD�D�D r( c �L � || j vrt d|� �� �|| _ | S )a� Set the stage before entering context. This enables the context manager to be initialized separately from each stage synchronization. :param stage: the name of a stage to synchronize Example: sync = SocketSync("stage 1", "stage 2"): with sync("stage 1"): pass with sync("stage 2"): pass zInvalid stage name: )r- � ValueErrorr( )r3 r( s r �__call__zSocketSync.__call__M s/ � � ����$��3�E�7�;�<�<��� ��� c �, � t j t j j � � rt j d� yd| _ t d| j � d�� t j � }| j | j }|j d� \ }| _ d|k7 r+| j ddd� t! dt# |� � d �� �t$ � d | j � d�t# | j � k7 r+| j ddd� t! d| j � �� �t j � |z }|d kD rd|d�d�nd}t d| j � d�� t j'