+
    i-                       a  R1 t(0 t R t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt R	R
R].R]RR./t] ^ k RRRRRRR/ R/ RRRR.RR/tRRRRR./RRRRR./R RR!RR.//t]P6                  ! ]4      tR" R# ltR2R$ ltR3R% lt R& R' lt!R( t"R4R) lt# ! R* R+4      t$R5R, lt%R- R. lt&R/ R0 lt'R# )6z-Rsyslog: Configure system logging via rsyslogN)	lifecyclesubputilCloud)Config)
MetaSchema)ALL_DISTROSDistro)loggers)PER_INSTANCEid
cc_rsyslogdistros	frequencyactivate_by_schema_keysrsyslog
config_dirz/etc/rsyslog.dconfig_filenamez20-cloud-config.confservice_reload_commandautoremotesconfigs	check_exersyslogdpackagesinstall_rsyslogFfreebsdz/usr/local/etc/rsyslog.dopenbsdzsysutils/rsyslognetbsdz/usr/pkg/etc/rsyslog.dc                $    V ^8  d   QhR\         /# )   distro)r
   )formats   "=/usr/lib/python3/dist-packages/cloudinit/config/cc_rsyslog.py__annotate__r%   ?   s      &     c                    \         p\        P                  ! \        4      pV P                  V9   d+   \        P
                  ! W!V P                  ,          .RR7      pV# )zConstruct a distro-specific rsyslog config dictionary by merging
   distro specific changes into base config.

@param distro: String providing the distro class name.
@returns: Dict of distro configurations for ntp clients.
T)reverse)DISTRO_OVERRIDEScopyRSYSLOG_CONFIGosfamilyr   mergemanydictname)r"   dcfgcfgs   &  r$   distro_default_rsyslog_configr1   ?   sF     D
))N
#C$  #FKK'8!94HJr&   c                `    \         P                  ! V4      '       d   R# Vf   R.pV ! V4       R# )aQ  Install rsyslog package if not already installed.

@param install_func: function.  This parameter is invoked with the contents
of the packages parameter.
@param packages: list.  This parameter defaults to ['rsyslog'].
@param check_exe: string.  The name of a binary that indicates the package
the specified package is already installed.
Nr   )r   which)install_funcr   r   s   &&&r$   r   r   M   s+     zz);r&   c                     VR 8X  d%   V P                  RR4      pV P                  RV4      # \        P                  ! VRR7      # )r   rsyslog_svcnamer   z
try-reloadT)capture)
get_optionmanage_servicer   )r"   commandservices   && r$   reload_syslogr<   ^   sA    &##$5yA$$\7;;99Wd++r&   c                <    V ^8  d   QhR\         R\        R\         /# )r!   r0   r"   return)dictr
   )r#   s   "r$   r%   r%   e   s!     , ,T ,6 ,d ,r&   c                   V P                  R/ 4      p\        V4      p\        V P                  R4      \        4      '       dR   \        P
                  ! RRR7       RV P                  R4      /pRV 9   d   V R,          VR&   RV 9   d   V R,          VR	&   R. \        3R	VR	,          \        3RVR,          \        3R
VR
,          \        3RVR,          \        \        33RVR,          \        3RVR,          \        3RVR,          \        33pV FM  w  rVpWR9  d   WbV&   K  \        W%,          V4      '       d   K,  \        RV RV R\        W%,          4       24      h	  V# )zReturn an updated config.

Support converting the old top level format into new format.
Raise a `ValueError` if some top level entry has an incorrect type.
r   z)The rsyslog key with value of type 'list'z22.2)
deprecateddeprecated_versionr   rsyslog_filenamer   rsyslog_dirr   r   r   r   r   r   zInvalid type for key `z`. Expected type(s): z. Current type: )getr1   
isinstancelistr   	deprecatestrr?   bool
ValueErrortype)r0   r"   mycfgdistro_configfillupkeydefaultvtypess   &&      r$   load_configrS   e   s}    GGIr"E1&9M#'')$d++B%	
 CGGI./$'*+='>E#$C"%m"4E, 
B	}\2C8	M*;<cB	M),d3$23$K	

 
mK0#6	]:.5	M*;<dCF !'f #JEJ//(-B6( K!!%ej!1 24 	 !' Lr&   c                    . p\        V 4       EF  w  rE\        V\        4      '       dC   R V9  d    \        P	                  RV^,           4       KB  VR ,          pVP                  RV4      pMTpTpVP                  4       pV'       g    \        P	                  RV^,           4       K  \        P                  P                  W'4      pRpWs9  d   RpVP                  V4        Rp	VP                  R4      '       g   Rp	\        P                  ! WvV	,           VR7       EK  	  V#   \         d"    \        P                  ! \        R	T4        EK@  i ; i)
contentz%No 'content' entry in config entry %sfilenamezEntry %s has an empty filenameabwb 
)omodezFailed to write to %s)	enumeraterF   r?   LOGwarningrE   stripospathjoinappendendswithr   
write_file	Exceptionlogexc)
r   	def_fnamecfg_dirfilescur_posentrU   rV   r[   endls
   &&&       r$   apply_rsyslog_changesrn      s&    E!'*c4  #;Wq[ )nGwwz95HG H>>#KK8'A+F77<<2  ELL"	@D##D))OOHnEBB= +D L  	@KK4h??	@s   "D#;!D##'EEc                     \         P                  ! R V 4      w  r#VP                  4       pVP                  4       P                  4       pRp\	        V4      ^8X  d   TpM'\	        V4      ^8X  d   Vw  rVM\        RV,          4      h\         P
                  ! RV4      pV'       g   \        RV,          4      hVP                  R4      pVP                  R4      ;'       g    VP                  R4      pVP                  R4      p	VP                  R	4      '       d*   VP                  R
4      '       g   \        RV,          4      hV'       d   V'       g   Tp\        WWxV	R7      p
V
P                  4        V
#   \         d    T Rr2 ELZi ; i)z[ ]*[#]+[ ]*Nzline had multiple spaces: %sz_^(?P<proto>[@]{0,2})(([\[](?P<bracket_addr>[^\]]*)[\]])|(?P<addr>[^:]*))([:](?P<port>[0-9]+))?$zInvalid host specification '%s'protoaddrbracket_addrport[]z"host spec had invalid brackets: %sr.   matchrp   rq   rs   )resplitr_   rK   lenrw   group
startswithrd   SyslogRemotesLinevalidate)liner.   datacommenttoksrw   	host_portrp   rq   rs   ts   &&         r$   parse_remotes_liner      sP   %$7--/ ::<DE
4yA~		Tay7$>??88	# 		D :YFGGJJwE::f;;N!;D::fDsDMM#$6$6=DEEteT	A JJLHI  %tg%s   )E4 4FFc                   <   a  ] tR t^t o RR ltR tR tR tRtV t	R# )r}   Nc                    V'       g   R pWn         W n        V'       g   RpVR8X  d   RpM	VR8X  d   RpW0n        W@n        Ve   \	        V4      V n        R# RV n        R# )z*.*udp@@@tcpN)r.   rw   rp   rq   intrs   )selfr.   rw   rp   rq   rs   s   &&&&&&r$   __init__SyslogRemotesLine.__init__   sV     E	
EC<Ed]E
	!%!1CI	t	r&   c                    V P                   '       d    \        V P                   4       V P                  '       g   \        R4      hR#   \         d#   p\        R T P                   ,          4      ThRp?ii ; i)zport '%s' is not an integerNzaddress is required)rs   r   rK   rq   )r   es   & r$   r~   SyslogRemotesLine.validate   se    999DII yyy233    1DII=s   A A5A00A5c                    R V P                   : RV P                  : RV P                  : RV P                  : RV P                  : R2# )z[name=z match=z proto=z	 address=z port=ru   rv   )r   s   &r$   __repr__SyslogRemotesLine.__repr__  s/    IIJJJJIIII
 	
r&   c                   V P                   R ,           pV P                  R8X  d   VR,          pMV P                  R8X  d
   VR,          pRV P                  9   d#   VRV P                  ,           R,           ,          pMWP                  ,          pV P                  '       d   VRV P                  ,          ,          pV P                  '       d   VR	V P                  ,          ,          pV# )
 r   r   r   r   :rt   ru   z:%sz # %s)rw   rp   rq   rs   r.   )r   bufs   & r$   __str__SyslogRemotesLine.__str__  s    jj3::3JCZZ5 4KC$))3?S((C99C9995499$$C9997TYY&&C
r&   )rq   rw   r.   rs   rp   )NNNNN)
__name__
__module____qualname____firstlineno__r   r~   r   r   __static_attributes____classdictcell__)__classdict__s   @r$   r}   r}      s     <$
4
 r&   r}   c           
         V '       g   R # . pVe   VP                  V4       V P                  4        F4  w  rEV'       g   K   VP                  \        \        WTR7      4      4       K6  	  Ve   VP                  V4       RP                  V4      R,           #   \         d#   p\
        P                  RYET4        R p?K  R p?ii ; i)N)r.   z!failed loading remote %s: %s [%s]rZ   )rc   itemsrI   r   rK   r]   r^   rb   )r   headerfooterlinesr.   r   r   s   &&&    r$   remotes_to_rsyslog_cfgr   $  s    EVmmo
	LLL/@AB	 & V99Ud""	  	LKK;TKK	Ls   $BC"B??Cc                (    V ^8  d   QhR\         RR/# )r!   cloudr>   Nr   )r#   s   "r$   r%   r%   6  s     
 
E 
d 
r&   c                    V P                   P                  RR4       T P                   P                  RR4       T P                   P	                  4        \
        P                  ! \        P                  4      ;_uu_ 4        T P                   P                  RR4       \        P                  R4       RRR4       R#   \        P                   d     R# i ; i  + '       g   i     R# ; i)z
This helper function bundles the necessary steps to disable BSD base syslog
``rc(8)`` reads its configuration on start, so after disabling syslogd, we
need to tell rc to reload its config
enabledsyslogdNdisableonestopzOsyslogd is running before cloud-init! Please report this as bug to the porters!)	r"   r9   r   ProcessExecutionErrorreload_init
contextlibsuppressr]   error)r   s   &r$    disable_and_stop_bsd_base_syslogr   6  s    ##Iy9 
LL	95	LL			T77	8	8 	##Iy9		8	
 
9	8 %% 
 
9	8	8s   B<  2C<CCC)	c          
      L    V ^8  d   QhR\         R\        R\        R\        RR/# )r!   r.   r0   r   argsr>   N)rI   r   r   rG   )r#   s   "r$   r%   r%   N  s/     =; =; =;6 =;% =;t =; =;r&   c                 Z   R V9  d   \         P                  RV 4       R# \        WP                  4      pVR,          pVR,          '       d%   VP	                  \        VR,          RRR7      4       VP                  P                  RR 4      pVR	,          R
J d1   \        VP                  P                  VR,          VR,          R7       \        P                  ! 4       '       d(   VP                  P                  RV4       \        V4       VR,          '       g   \         P                  R4       R# \        VR,          VR,          VR,          R7      pV'       g   \         P                  R4       R#  \        VP                  VR,          R7      pV'       dN   \&        P(                  ! 4        \&        P*                  ! VP,                  4       \         P                  RW4       R# R#   \        P                    d,   p	Rp\         P#                  R\%        T	4      4        Rp	?	LRp	?	ii ; i)r   z;Skipping module named %s, no 'rsyslog' key in configurationNr   r   z# begin remotesz# end remotes)r   r   r6   r   Tr   r   )r   r   enablez.Empty config rsyslog['configs'], nothing to dor   r   )r   rh   ri   z0restart of syslog not necessary, no changes mader   )r:   FzFailed to reload syslog %sz%s configured %s files)r]   debugrS   r"   rc   r   r8   r   install_packagesr   is_BSDr9   r   rn   r<   r   r   r^   rI   r   reset_loggingsetup_loggingr0   )
r.   r0   r   r   rM   r   r;   changes	restartedr   s
   &&&&      r$   handler   N  s   		I4	
 	\\*EIGY"i (&	
 ll%%&7CG4'LL)):&K(	
 {{}}##Hg6(/		BC#i )*l#G 		DE:!LL%(@"A
	  	eii( 			*D: 	 %% :	0#a&99:s   5G* *H*?!H%%H*c                @    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r!   meta)__conditional_annotations__r   )r#   s   "r$   r%   r%      s     3 3  j ! 4r&   )Nr   )r   )N)NN))r   __doc__r   r*   loggingr`   rx   	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.distrosr	   r
   cloudinit.logr   cloudinit.settingsr   r   r+   r)   	getLoggerr   r]   r1   r   r<   rS   rn   r   r}   r   r   r   r%   )r   s   @r$   <module>r      s+   4    	 	 + + ! # . 1 ! + 	,}	{	  "-frru	 0YK 0'( .'(  !",,^&R(V9 9x#$
0=;r&   