1 #ˆl–ß=¿J µ2ÛR‚œP-\l˜´o ƒiÑÁÀ¿qa '¡Dg´ã@srdZddlZddlZddlZddlZddlmZddlmZddl m Z e  e ¡Z edœdd„ZGd d „d ƒZdS) z#A module for common socket helpers.éN)Úsuppress)Ú performance)ÚDEFAULT_RUN_DIR)ÚmessagecCsªtj dd¡}|sdS|ddkr2| ddd¡n|ddkrFtd ƒ‚t tjtjtjB¡�:}t   d t |ƒ¡|  |¡|  | d ¡¡Wdƒn1sœ0YdS) z[Send a sd_notify message. :param message: sd-notify message (must be valid ascii) Z 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Úsock©rú4/usr/lib/python3.9/site-packages/cloudinit/socket.pyÚ sd_notifys  ÿ rc@s<eZdZdZedœdd„Zedœdd„Zdd „Zd d „Zd S) Ú SocketSyncz>sýÿz'SocketSync.__init__..z/shareiÀT)ÚmodeÚexist_okú/share/z.sockN)ÚstageÚremoteÚfirst_exceptionÚsystemd_exit_codeÚexperienced_any_errorÚsocketsr ÚmakedirsrÚitemsrÚFileNotFoundErrorÚremoveZbind)Úselfr!r#rrrrrÚ__init__-s ü (zSocketSync.__init__)r(cCs"||jvrtd|›�ƒ‚||_|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()r2r(rrrÚ__call__Ms zSocketSync.__call__cCst tj ¡¡rt d¡dSd|_td|j ›d�ƒ|j |j }t   d|j ›�¡� |  d¡\}|_Wdƒn1sz0Yd|kr°| ddd¡td t|ƒ›d �ƒ‚n:t›d |j ›d �t|jƒkrê| ddd¡td |j›�ƒ‚td|j ›d�ƒ|S)z‡Wait until a message has been received on this stage's socket. Once the message has been received, enter the context. z:Stdin is a tty, so skipping stage synchronization protocolNrzDSTATUS=Waiting on external services to complete before starting the z stage.zWaiting to start stage ésstartzReceived invalid message: [ú]r'z -return.sockz Unexpected path to unix socket: zSTATUS=Running (z stage))r ÚisattyÚsysÚstdinÚfilenorrr+rr(r-rZTimedZrecvfromr)Ú__exit__r4rr)r2rÚchunkrrrÚ __enter__as0ÿÿÿ .ÿzSocketSync.__enter__cCs¬d|j›�}|rXd|_d|_t|ƒ›d|j›�}d}|js@||_t |¡td|›�ƒ|jpft |jƒ|_|j |j}|  |j ¡|  d|›d|j›d � ¡¡| ¡dS) z.Notify the socket that this stage is complete.z,Completed socket interaction for boot stage r Tz in zk