+
    im&                     *   R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt RtRtRt]P$                  ! ]4      t ! R	 R
]4      t]! R4      t ! R R4      t ! R R]4      tRR lt]P6                  R3R ltR t ! R R4      tR tR# )z
events for reporting.

The events here are designed to be used with reporting.
They can be published to registered handlers with report_event.
N)List)performance)available_handlersinstantiated_handler_registry)ReportingHandlerfinishstart	cloudinitc                   &   a  ] tR t^t o R tRtV tR# )_namesetc                6    W9   d   V# \        R V,          4      h)z%s not a valid value)AttributeError)selfnames   &&</usr/lib/python3/dist-packages/cloudinit/reporting/events.py__getattr___nameset.__getattr__    s    <K3d:;;     N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     < <r   r   c                   >   a  ] tR t^)t o Rt]R3R ltR tR tRt	V t
R# )ReportingEventz"Encapsulation of event formatting.Nc                t    Wn         W n        W0n        W@n        Vf   \        P                  ! 4       pWPn        R # N)
event_typer   descriptionorigintime	timestamp)r   r!   r   r"   r#   r%   s   &&&&&&r   __init__ReportingEvent.__init__,   s/     %	&		I"r   c                d    RP                  V P                  V P                  V P                  4      # )z"The event represented as a string.z{0}: {1}: {2})formatr!   r   r"   r   s   &r   	as_stringReportingEvent.as_string<   s*    %%OOTYY(8(8
 	
r   c           
     ~    RV P                   RV P                  RV P                  RV P                  RV P                  /# )z&The event represented as a dictionary.r   r"   r!   r#   r%   )r   r"   r!   r#   r%   r*   s   &r   as_dictReportingEvent.as_dictB   s=     DII4++$//dkk
 	
r   )r"   r!   r   r#   r%   )r   r   r   r   __doc__DEFAULT_EVENT_ORIGINr&   r+   r.   r   r   r   s   @r   r   r   )   s$     , $# 

 
r   r   c                   `   a a ] tR t^Mt o]P
                  R3V 3R lltR tV 3R ltRt	Vt
V ;t# )FinishReportingEventNc                   < \         \        V `  \        W4       W@n        Vf   . pWPn        W0n        V\        9  d   \        RV,          4      hR # )NzInvalid result: %s)	superr3   r&   FINISH_EVENT_TYPEresult
post_filesdurationstatus
ValueError)r   r   r"   r9   r7   r8   	__class__s   &&&&&&r   r&   FinishReportingEvent.__init__N   sT     	"D2t	
 J$ 1F:;;  r   c                    R P                  V P                  V P                  V P                  V P                  V P
                  4      # )z'{0}: {1}: {2}: {3} (duration: {4:.3f}s))r)   r!   r   r7   r"   r9   r*   s   &r   r+   FinishReportingEvent.as_stringa   s:    8??OOIIKKMM
 	
r   c                   < \         \        V `  4       pV P                  VR&   \	        V P
                  ^4      VR&   V P                  '       d   \        V P                  4      VR&   V# )z'The event represented as json friendly.r7   r9   files)r5   r3   r.   r7   roundr9   r8   _collect_file_info)r   datar<   s   & r   r.   FinishReportingEvent.as_dictj   sU    )48:X 2Z???.t?DMr   )r9   r8   r7   )r   r   r   r   r:   SUCCESSr&   r+   r.   r   r   __classcell__)r<   r   s   @@r   r3   r3   M   s%      ~~<&
 r   r3   c                >   V'       g   / p\         P                  P                  4        UUu0 uF  w  r#W!9   g   K  VkK  	  ppp\        \        P                  P                  4       4      pV F&  p\        V4      V9   d   K  VP                  V 4       K(  	  R# u uppi )a  Report an event to all registered event handlers
except those whose type is in excluded_handler_types.

This should generally be called via one of the other functions in
the reporting module.

:param excluded_handler_types:
     List of handlers types to exclude from reporting the event to.
:param event_type:
    The type of the event; this should be a constant from the
    reporting module.
N)r   registered_itemsitemslistr   valuestypepublish_event)eventexcluded_handler_types	hndl_typehndl_clsexcluded_handler_classeshandlershandlers   &&     r   report_eventrV   t   s     "!# $6#F#F#L#L#N #NI. 	#N    (,%66==?(H =44e$  s
   
BBc                4    \        WW#VR7      p\        V4      # )zNReport a "finish" event.

See :py:func:`.report_event` for parameter details.
)r8   )r3   rV   )
event_nameevent_descriptionr9   r7   r8   rO   s   &&&&& r   report_finish_eventrZ      s"     !xJE r   c                8    \        \        W4      p\        V4      # )a  Report a "start" event.

:param event_name:
    The name of the event; this should be a topic which events would
    share (e.g. it will be the same for start and finish events).

:param event_description:
    A human-readable description of the event that has occurred.
)r   START_EVENT_TYPErV   )rX   rY   rO   s   && r   report_start_eventr]      s     +ZKEr   c                      a  ] tR t^t o RtRRR]P                  R3R ltR tR t	R t
]R 4       t]P                  R 4       t]R	 4       t]P                  R
 4       tR tR tRtV tR# )ReportEventStacka  Context Manager for using :py:func:`report_event`

This enables calling :py:func:`report_start_event` and
:py:func:`report_finish_event` through a context manager.

:param name:
    the name of the event

:param description:
    the event's description, passed on to :py:func:`report_start_event`

:param message:
    the description to use for the finish event. defaults to
    :param:description.

:param parent:
:type parent: :py:class:ReportEventStack or None
    The parent of this event.  The parent is populated with
    results of all its children.  The name used in reporting
    is <parent.name>/<name>

:param reporting_enabled:
    Indicates if reporting events should be generated.
    If not provided, defaults to the parent's value, or True if no parent
    is provided.

:param result_on_exception:
    The result value to set if an exception is caught. default
    value is FAIL.

:param post_files:
    Can hold filepaths of files that are to get posted/created
    regarding a given event. Something like success or failure information
    in a given log file. For each filepath, if it's a valid regular file
    it will get: read & encoded as base64 at the close of the event.
    Default value, if None, is an empty list.
Nc                Z   W@n         Wn        W n        W0n        W`n        \
        P                  V n        R V n        Vf   . pWpn	        Vf   V'       d   VP                  pMRpWPn
        V'       d$   RP                  VP                  V34      V n        MV P                  V n        / V n        R # )NT/)parentr   r"   messageresult_on_exceptionr:   rF   r7   start_timestampr8   reporting_enabledjoinfullnamechildren)r   r   r"   rc   rb   rf   rd   r8   s   &&&&&&&&r   r&   ReportEventStack.__init__   s     	&#6 nn#J$ $$*$<$<!$(!!2HHOODM !IIDMr   c                \    R V P                   : RV P                  : RV P                  : R2# )zReportEventStack(z, z, reporting_enabled=))r   r"   rf   r*   s   &r   __repr__ReportEventStack.__repr__  s%    II""
 	
r   c                2   \         P                  V n        \        P                  ! 4       V n        V P                  '       d!   \        V P                  V P                  4       V P                  '       d$   RV P                  P                  V P                  &   V # )N)NN)r:   rF   r7   r$   	monotonicre   rf   r]   rh   r"   rb   ri   r   r*   s   &r   	__enter__ReportEventStack.__enter__  sb    nn#~~/!!!t}}d.>.>?;;;.:DKK  +r   c                    \         P                  \         P                  3 F@  pV P                  P	                  4        F  w  pw  r4W18X  g   K  W0P
                  3u u # 	  KB  	  V P                  V P
                  3# r    )r:   FAILWARNri   rJ   rc   r7   )r   cand_result_namevalue_msgs   &    r   _childrens_finish_info'ReportEventStack._childrens_finish_info  s_    "KK5K(,(;(;(=$}'!<<00 )> 6 T\\**r   c                    V P                   # r    )_resultr*   s   &r   r7   ReportEventStack.result  s    ||r   c                L    V\         9  d   \        R V,          4      hWn        R# )z'%s' not a valid resultN)r:   r;   r}   r   rx   s   &&r   r7   r~     s     6>??r   c                N    V P                   e   V P                   # V P                  # r    )_messager"   r*   s   &r   rc   ReportEventStack.message"  s"    ==$== r   c                    Wn         R # r    )r   r   s   &&r   rc   r   (  s    r   c                b    V'       d   V P                   V P                  3# V P                  4       # r    )rd   rc   rz   )r   excs   &&r   _finish_infoReportEventStack._finish_info,  s)    ,,dll;;**,,r   c                v   V P                  V4      w  rEV P                  '       d%   WE3V P                  P                  V P                  &   V P                  '       d^   V P
                  e(   \        P                  ! 4       V P
                  ,
          pMRp\        V P                  VVVV P                  R7       R # R # )Ng        )r9   r7   r8   )r   rb   ri   r   rf   re   r$   rp   rZ   rh   r8   )r   exc_type	exc_value	tracebackr7   msgr9   s   &&&&   r   __exit__ReportEventStack.__exit__2  s    )))4;;;/5mDKK  +!!!##/>>+d.B.BB!?? "r   )r   r}   ri   r"   rh   rc   r   rb   r8   rf   r7   rd   re   )r   r   r   r   r0   r:   rt   r&   rm   rq   rz   propertyr7   setterrc   r   r   r   r   r   s   @r   r_   r_      s     $T "KK&P
+   ]] 
    
 ^^ - r   r_   c           
         V '       g   R # . pV  F  p\         P                  P                  V4      '       g   R pMy\        P                  ! RV 24      ;_uu_ 4        \        VR4      ;_uu_ 4       p\        P                  ! VP                  4       4      P                  4       pR R R 4       R R R 4       VP                  RVRXRR/4       K  	  V#   + '       g   i     L5; i  + '       g   i     L@; i)NzReading rbpathcontentencodingbase64)osr   isfiler   Timedopenr   	b64encodereaddecodeappend)rA   retfnamer   fps   &    r   rC   rC   D  s    
Cww~~e$$G""XeW#566t9 9 **27795<<>96 	

FE9gz8LM  J9 966s$   C#03C#C#C C##C3)rF   ru   rt   r    ) r0   r   loggingos.pathr   r$   typingr   r	   r   cloudinit.reportingr   r   cloudinit.reporting.handlersr   r6   r\   r1   	getLoggerr   LOGsetr   r:   r   r3   rV   rF   rZ   r]   r_   rC   r   r   r   <module>r      s   
      ! :  " !<s < 
-	.!
 !
H$> $N%F >>"O Odr   