+
    iF                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	 ^ RI
Ht ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHt Rt ]PB                   ! R R]PD                  4      4       t#]PB                   ! R R]PD                  4      4       t$]PB                   ! R R]PD                  4      4       t%]&! ]%PN                  ]%PP                  ]%PR                  ]%PT                  .4      t+ ! R R]4      t,Rt-R R lt.R4R lt/R R lt0R R lt1R R lt2R R lt3R  R! lt4R" R# lt5R$ R% lt6R& R' lt7R( R) lt8R* R+ lt9R, t:R- t;R. R/ lt<R5R0 R1 llt=R2 t>]?R38X  d
   ]>! 4        R# R# )6zGDefine 'status' utility and handler as part of cloud-init command line.N)deepcopy)datetimetimezone)sleep)AnyDictList
NamedTupleOptionalTuple)safeyamlsubp)read_cfg_paths)uses_systemd)Paths)get_cmdline	load_jsonload_text_filez/etc/cloud/cloud-init.disabledc                   *    ] tR t^tRtRtRtRtRtRt	R# )RunningStatusz=Enum representing user-visible cloud-init application status.znot startedrunningdonedisabled N)
__name__
__module____qualname____firstlineno____doc__NOT_STARTEDRUNNINGDONEDISABLED__static_attributes__r       6/usr/lib/python3/dist-packages/cloudinit/cmd/status.pyr   r      s    GKGDHr$   r   c                   &    ] tR t^&tRtRtRtRtRtR# )ConditionStatusz;Enum representing user-visible cloud-init condition status.errordegradedhealthyr   N)	r   r   r   r   r   ERRORDEGRADEDPEACHYr#   r   r$   r%   r'   r'   &   s    EEHFr$   r'   c                   :    ] tR t^/tRtRtRtRtRtRt	Rt
RtR	tR
tR# )EnabledStatusz<Enum representing user-visible cloud-init boot status codes.zdisabled-by-generatorzdisabled-by-kernel-command-linezdisabled-by-marker-filez disabled-by-environment-variablezenabled-by-generatorzenabled-by-kernel-command-linezenabled-by-sysvinitunknownr   N)r   r   r   r   r   DISABLED_BY_GENERATORDISABLED_BY_KERNEL_CMDLINEDISABLED_BY_MARKER_FILEDISABLED_BY_ENV_VARIABLEENABLED_BY_GENERATORENABLED_BY_KERNEL_CMDLINEENABLED_BY_SYSVINITUNKNOWNr#   r   r$   r%   r/   r/   /   s4    F3!B7A1 @/Gr$   r/   c                   ,   a  ] tR t^Gt o V 3R ltRtV tR# )StatusDetailsc                   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[S[S[,          3,          ;R&   S[;R&   S[S[,          ;R&   S[S[S[3,          ;R	&   # )
   running_statuscondition_statusboot_status_codedescriptionerrorsrecoverable_errorslast_update
datasourcev1)r   r'   r/   strr   r   r
   r   )format__classdict__s   "r%   __annotate__StatusDetails.__annotate__G   s     !! %%  $#  	 
 I  S$s)^,,      	S#X r$   r   N)r   r   r   r   __annotate_func__r#   __classdictcell__)rH   s   @r%   r:   r:   G   s      r$   r:   zextended_status: {extended_status}
boot_status_code: {boot_code}
{last_update}detail: {description}
errors:{errors}
recoverable_errors:{recoverable_errors}c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r<   systemctl_argswaitreturn)r   rF   bool)rG   s   "r%   rI   rI   [   s,      I  		r$   c                     \         P                   ! R.V O4      P                  P                  4       #   \         P                   d    T'       g   h \	        R4        K_  i ; i)z-Query systemd with retries and return output.	systemctl      ?)r   stdoutstripProcessExecutionErrorr   )rN   rO   s   &$r%   query_systemctlrX   [   sT     	99k;N;<CCIIKK)) 	$K	s   04 A!A! A!c                    V '       g   \         P                  ! RRR7      p V P                  R\        . RORRR7       V P                  RR	R
RRR7       V P                  RRR
RRR7       V # )a  Build or extend an arg parser for status utility.

@param parser: Optional existing ArgumentParser instance representing the
    status subcommand which will be extended to support the args of
    this utility.

@returns: ArgumentParser with proper argument configuration.
statuszReport run status of cloud init)progr@   z--formattabularz5Specify output format for cloud-id (default: tabular))typechoicesdefaulthelpz-lz--long
store_trueFzJReport long format of statuses including run stage name and error messages)actionr_   r`   z-wz--waitz'Block waiting on cloud-init to complete)jsonr\   yaml)argparseArgumentParseradd_argumentrF   parsers   &r%   
get_parserrj   j   s     (('H
 +D     	 6   Mr$   c                ^    V ^8  d   QhR\         R\        R\        \        \        3,          /# )r<   r   	conditionrP   )r   r'   r   rF   )rG   s   "r%   rI   rI      s,     ( (('6(
38_(r$   c                X   V\         P                  8X  d   RVP                   RV P                   23# V\         P                  8X  dM   V \        P
                  \        P                  39   d(   V P                  VP                   RV P                   23# V P                  V P                  3# )zTranslate running and condition status to human readable strings.

Returns (status, extended_status).
Much of this is for backwards compatibility
r(   z -  )r'   r+   valuer,   r   r!   r    )r   rl   s   &&r%   translate_statusrp      s     O)))9??+3w}}o>>>	o..	.7? 4 }} 17==/BBB=='--''r$   c                $    V ^8  d   QhR\         /# )r<   details)r:   )rG   s   "r%   rI   rI      s     ?, ?, ?,r$   c                   \        VP                  VP                  4      w  r#RVP                  RVP                  P
                  RVRVRVP                  RVP                  RVP                  RVP                  /VP                  CpV P                  R	8X  EdP   R
pVR,          p\        V RV 24       V P                  '       Ed    VP                  R4      '       d   RVR,           R2pMR
pVR,          '       d    RRP                  VR,          4      ,           MRpVR,          '       d|   RRP                  VR,          P!                  4        U	U
Uu. uF?  w  rV	 R2RP                  V
 Uu. uF  qP#                  RR4      NK  	  up4      ,           NKA  	  upp
p	4      ,           MRp\        \$        P                  VR,          VVR,          VR,          VVVR7      4       R# R# V P                  R8X  d&   \        \&        P(                  ! V^RRR7      4       R# V P                  R8X  d"   \        \*        P(                  ! V4      4       R# R# u upi u upp
p	i )zPrint status out to the CLI.rD   r?   rZ   extended_statusdetailrA   rB   rC   r\    zstatus: zlast_update: 
z
	- z []z:
	- rn   z {})rt   prefix	boot_coder@   rC   rA   rB   rc   T)indent	sort_keys
separatorsrd   N),z: )rp   r=   r>   rD   r?   ro   r@   rA   rB   rC   rE   rG   printlonggetjoinitemsreplaceTABULAR_LONG_TMPLrc   dumpsr   )argsrr   rZ   rt   details_dictrx   staterC   errors_outputkvirecoverable_errors_outputs   &&           r%   print_statusr      sQ   . 8 8F 	g((G44::&?'%%'..g88w**
$ **
$L {{i X&()999.. -l=.I-J"M   )) 8==h)?@@    455 )) %11E$F$L$L$N %ODA #W"--q(Iq!4)=q(IJK K$N  & !(($01B$C!*+=> ,X 6 +('@ ) 
- B 
	JJQ$;	

 
	hnn\*+ 
1 )Js   I.IIIc                $    V ^8  d   QhR\         /# r<   rP   )int)rG   s   "r%   rI   rI      s      c r$   c                @   \        4       p\        W!P                  4      pVP                  '       d   VP                  \        P
                  \        P                  39   dq   VP                  R8X  d>   \        P                  P                  R4       \        P                  P                  4        \        W!P                  4      p\        R4       K  \        W4       VP                  \        P                   8X  d   ^# VP                  \        P"                  8X  d   ^# ^ # )z4Handle calls to 'cloud-init status' as a subcommand.r\   .rT   )r   get_status_detailsrO   r=   r   r   r    rG   sysrU   writeflushr   r   r>   r'   r+   r,   )namer   pathsrr   s   &&  r%   handle_status_argsr      s     E 		2Gyyy$$%%!!)
 
 {{i'

  %

  "(		:G$K ?#8#88		!	!_%=%=	=r$   c                $    V ^8  d   QhR\         /# r   rQ   )rG   s   "r%   rI   rI     s     ( (t (r$   c                l     \        R.V R7      pRV9   #   \        P                   d
    Rp RT9   # i ; i)z?Return whether cloud-init is disabled via environment variable.zshow-environmentrO   rv   cloud-init=disabled)rX   r   rW   )rO   envs   & r%   _disabled_via_environmentr     sK    12> !C'' %%  C''s    33c                F    V ^8  d   QhR\         \        \        3,          /# r   )r   r/   rF   )rG   s   "r%   rI   rI     s     '% '%}c7I1J '%r$   c                   \        4       P                  4       p\        4       '       g   \        P                  pRpWE3# RV9   d   \        P
                  pRpWE3# \        P                  P                  V 4      '       d%   \        P                  pRP                  V 4      pWE3# RV9   d   \        P                  pRpWE3# R\        P                  P                  RR4      9   g#   \        4       '       d(   \        VR	7      '       d   \        P                  pR
pWE3# \        P                  P                  \        P                  P!                  VP"                  R4      4      '       d   \        P$                  pRpWE3# \        P                  P                  \        P                  P!                  VP"                  R4      4      '       d   \        P&                  pRpWE3# \        P(                  pRpWE3# )a@  Report whether cloud-init current boot status

@param disable_file: The path to the cloud-init disable file.
@param paths: An initialized cloudinit.helpers.Paths object.
@param wait: If user has indicated to wait for cloud-init to complete.
@returns: A tuple containing (code, reason) about cloud-init's status and
why.
zCloud-init enabled on sysvinitzcloud-init=enabledz<Cloud-init enabled by kernel command line cloud-init=enabledzCloud-init disabled by {0}r   z;Cloud-init disabled by kernel parameter cloud-init=disabledKERNEL_CMDLINErv   r   zNCloud-init disabled by environment variable KERNEL_CMDLINE=cloud-init=disabledr   z+Cloud-init disabled by cloud-init-generatorenabledz2Cloud-init enabled by systemd cloud-init-generatorz'Systemd generator may not have run yet.)r   splitr   r/   r7   r6   ospathexistsr3   rG   r2   environr   r   r4   r   run_dirr1   r5   r8   )disable_filer   rO   cmdline_partsbootstatus_codereasons   &&&   r%   get_bootstatusr     s     M'')M>>';;16 $$5 
	.'AAO0 $$/ 
	%	%'??-44\B* $$) 
-	/'BBN$ $$# 
"**..1A2"F	F4$??'@@1 	 $$ 
U]]J?	@	@'==> $$ 
U]]I>	?	?'<<E $$ (//:$$r$   c                $    V ^8  d   QhR\         /# r   r   )rG   s   "r%   rI   rI   6  s      t r$   c                  J    \        \        4       4      P                  \        9  # N)r   r   r?   DISABLED_BOOT_CODESr   r$   r%   is_cloud_init_enabledr   6  s     >+,=="	#r$   c                0    V ^8  d   QhR\         R\         /# )r<   rO   rP   r   )rG   s   "r%   rI   rI   =  s     8 8 8$ 8r$   c                   R F  p \        RRV.V R7      p\        TP                  4        UUu. uF0  qDP                  R4       Uu. uF  qUP                  4       NK  	  upNK2  	  upp4      pTR	,          P                  R
4      '       g   TR	,          R8X  g    R# TR,          R8X  d3   TR,          R8X  d   K  TR,          R8X  d   TR,          R8X  d    R#  R# TR,          R8X  g   TR,          R8X  d    R#  R# 	  R#   \        P                   d5   p\        RTP                   2\
        P                  R7        Rp? R# Rp?ii ; iu upi u uppi )z2Return if systemd units report a cloud-init error.showz5--property=ActiveState,UnitFileState,SubState,MainPIDr   z^Failed to get status from systemd. Cloud-init status may be inaccurate. Error from systemctl: )fileNF=UnitFileStater   staticTActiveStateactiveSubStateexitedr   MainPID0failed)zcloud-final.servicezcloud-config.servicezcloud-init-network.servicezcloud-init-local.servicezcloud-init-main.service)rX   r   rW   r~   stderrr   dict
splitlinesr   rV   
startswith)rO   servicerU   erxstatess   &      r%   systemd_failedr   =  sO   	$K
 F" 8>8I8I8KL8K1.Aggi.8KL
 ?#..y99o&(2 M"h.j!X-
#y0VI5F#5M   =!X-
1Cx1O gl M )) 	))*
4 ZZ	 	 /Ls.   DEEEE(EEEc                $    V ^8  d   QhR\         /# r   r   )rG   s   "r%   rI   rI   x  s     K KD Kr$   c                    \         P                  P                  V 4      ;'       d%    \         P                  P                  V4      '       * # )z%Return True if cloud-init is running.)r   r   r   )status_fileresult_files   &&r%   
is_runningr   x  s-    77>>+&JJrww~~k/J+JJr$   c                $    V ^8  d   QhR\         /# r   )r   )rG   s   "r%   rI   rI   }  s     ) ))r$   c                    V\         9   d   \        P                  # \        W4      '       d   \        P                  # V^ 8  d   \        P
                  # \        P                  # )z(Return the running status of cloud-init.)r   r   r"   r   r    r!   r   )r   r   r?   latest_events   &&&&r%   get_running_statusr   }  sP     ..%%%	K	-	-$$$		!!!(((r$   c                $    V ^8  d   QhR\         /# r   )rF   )rG   s   "r%   rI   rI     s     	 	 	r$   c                    V P                  RR4      pV'       d6   VP                  R4      w  p pVP                  4       P                  RR4      pV# )zqGet the datasource from status.json.

Return a lowercased non-prefixed version. So "DataSourceEc2" becomes "ec2"
rD   rv   rn   )r   	partitionlowerr   )	status_v1rD   ds_s   &   r%   get_datasourcer     sK    
 |R0J'',AqXXZ''b9
r$   c                    V P                  R4      pV'       d   V# V P                  R4      '       d   RV R,           2# V# )zReturn a description of the current status.

If we have a datasource, return that. If we're running in a particular
stage, return that. Otherwise, return the boot_description.
rD   stagezRunning in stage: )r   )r   boot_descriptionrD   s   && r%   get_descriptionr     sC     |,J	w		#Ig$6#788r$   c                    ^ pV P                  4        FZ  p\        V\        4      '       g   K  \        TVP	                  R4      ;'       g    ^ VP	                  R4      ;'       g    ^ 4      pK\  	  V# )z,Return the latest event time from status_v1.startfinished)values
isinstancer   maxr   )r   r   
stage_infos   &  r%   get_latest_eventr     sd    L&&(
j$''w',,1z*//aL ) r$   c                F    V ^8  d   QhR\         \        \        3,          /# r   )r   r   r   )rG   s   "r%   rI   rI     s     & &U4:. &r$   c                   . p/ p\        V P                  4       4       F  w  r4\        V\        4      '       g   K  VP	                  VP                  R. 4      4       VP                  R/ 4      pVP                  4        F;  pWb9  d   \        WV,          4      W&&   K  W&,          P	                  WV,          4       K=  	  K  	  W3# )z>Return a list of errors and recoverable_errors from status_v1.rA   rB   )sortedr   r   r   extendr   keysr   )r   rA   rB   _keyr   current_recoverable_errorserr_types   &      r%   
get_errorsr     s    F"9??#45j$''MM*..267 *4$b*& 7;;=53;2<4&0 '0772< > 6" %%r$   c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r<   r   rO   rP   )r
   r   rQ   r:   )rG   s   "r%   rI   rI     s-     D DE?D)-DDr$   c                $   \         P                  pT ;'       g    \        4       p \        P                  P                  V P                  R4      p\        P                  P                  V P                  R4      p\        \        W4      w  rV/ p\        P                  P                  V4      '       d%   \        \        V4      4      P                  R/ 4      p\        V4      p\        Wv4      p	\        V4      p
V
'       d9   \         P"                  ! V
\$        P&                  R7      pVP)                  R4      pMRp\+        V4      w  rV'       d   \         P,                  pMV'       d   \         P.                  p\1        W4WZ4      pV\2        P4                  8X  dV   \7        4       '       dF   \9        VR7      '       d4   \2        P:                  p\         P,                  pRp	VP=                  R	4       VP?                  R
R4       \A        VVVV	VVVVV4	      # )zReturn a dict with status, details and errors.

@param paths: An initialized cloudinit.helpers.paths object.
@param wait: If user has indicated to wait for cloud-init to complete.

Values are obtained from parsing paths.run_dir/status.json.
zstatus.jsonzresult.jsonrE   )tzz%a, %d %b %Y %H:%M:%S %zrv   r   z"Failed due to systemd unit failurezFailed due to systemd unit failure. Ensure all cloud-init services are enabled, and check 'systemctl' or 'journalctl' for more information.rD   N)!r'   r-   r   r   r   r   r   r   CLOUDINIT_DISABLED_FILEr   r   r   r   r   r   r   r   fromtimestampr   utcstrftimer   r+   r,   r   r   r    r   r   r!   appendpopr:   )r   rO   r>   r   r   r?   r   r   rD   r@   r   dtrC   rA   rB   r=   s   &&              r%   r   r     s    '--%%^%E'',,u}}m<K'',,u}}m<K)7*& I	ww~~k""n[9:>>tRH		*J!)>K#I.L##LX\\Bkk"<=!+I!6F*00	*33'"2N
 	-///NN%%&++*00:$	
 MM,%
 
r$   c                 v    \        4       p \        P                  ! \        RV P	                  4       4      4       R# )z$Tool to report status of cloud-init.rZ   N)rj   r   exitr   
parse_argsrh   s    r%   mainr    s&    \FHH&*;*;*=>?r$   __main__r   )NF)@r   re   enumrc   r   r   copyr   r   r   timer   typingr   r   r   r	   r
   r   	cloudinitr   r   cloudinit.cmd.develr   cloudinit.distrosr   cloudinit.helpersr   cloudinit.utilr   r   r   r   uniqueEnumr   r'   r/   	frozensetr1   r2   r3   r4   r   r:   r   rX   rj   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r$   r%   <module>r     se   N    	 
  '  ? ? $ . * # A A:  DII   dii   
DII 
 
  ++00--..	 	J 	+ %P((?,D6('%T8vK
)	 
&0DN@ zF r$   