
    x[h"                         S SK r S SKrS SKrS SKJrJr  \ R                  " \5      r " S S\	5      r
 " S S5      r " S S5      r " S	 S
\5      r " S S\5      rg)    N)subputilc                       \ rS rSrSrg)CustomScriptNotFound    N)__name__
__module____qualname____firstlineno____static_attributes__r       [/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/config_custom_script.pyr   r      s    r   r   c                   \    \ rS rSrSrSr\R                  R                  \\5      r	Sr
SrSrg)CustomScriptConstant   z/root/.customizationzcustomize.shz)/.guest-customization-post-reboot-pendingzpost-customize-guest.shr   N)r	   r
   r   r   CUSTOM_TMP_DIRCUSTOM_SCRIPT_NAMEospathjoinCUSTOM_SCRIPTPOST_CUSTOM_PENDING_MARKERPOST_CUSTOM_SCRIPT_NAMEr   r   r   r   r   r      s0    +N (GGLL1CDM!L7r   r   c                        \ rS rSrS rS rSrg)RunCustomScript    c                 d    Xl         X l        [        R                  R	                  X!5      U l        g N)
scriptname	directoryr   r   r   
scriptpath)selfr    r!   s      r   __init__RunCustomScript.__init__!   s     $"'',,y=r   c                 .   [         R                  R                  U R                  5      (       d  [	        SU R                  -  5      e[
        R                  " [        R                  5        [        R                  S[        R                  5        [
        R                  " U R                  [        R                  5        [
        R                  " [        R                  5      R                  SS5      n[
        R                  " [        R                  USS9  g )Nz3Script %s not found!! Cannot execute custom script!zCopying custom script to %s id  )mode)r   r   existsr"   r   r   
ensure_dirr   r   LOGdebugr   copyload_text_filereplace
write_file)r#   contents     r   prepare_scriptRunCustomScript.prepare_script&   s    ww~~doo..&E//" 
 	,;;<		)+?+M+M	
 			$//#7#E#EF %% ..

'$
 	 	 ..e	
r   )r!   r    r"   N)r	   r
   r   r   r$   r3   r   r   r   r   r   r       s    >

r   r   c                       \ rS rSrS rSrg)PreCustomScript=   c                     [         R                  S5        U R                  5         [        R                  " [        R
                  S/5        g)z7Executing custom script with precustomization argument.z"Executing pre-customization scriptprecustomizationN)r,   r-   r3   r   r   r   )r#   s    r   executePreCustomScript.execute>   s4    		67		'557IJKr   r   N)r	   r
   r   r   r:   r   r   r   r   r6   r6   =   s    Lr   r6   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )PostCustomScriptE   c                    > [         [        U ]  X5        X0l        [        R
                  R                  U[        R                  5      U l	        g r   )
superr=   r$   ccScriptsDirr   r   r   r   r   ccScriptPath)r#   r    r!   rA   	__class__s       r   r$   PostCustomScript.__init__F   s:    .zE(GGLL.FF
r   c                 <   U R                  5         [        R                  SU R                  5        [        R
                  " [        R                  R                  U R                  [        R                  5      U R                  5        [        R                  " U R                  5      n[        R                  " U R                  UR                  [        R                  -  5        [        R!                  S5        [        R"                  " [        R$                  5        g)z
This method copy the post customize run script to
cc_scripts_per_instance directory and let this
module to run post custom script.
z'Copying post customize run script to %sz*Creating post customization pending markerN)r3   r,   r-   rB   r   r.   r   r   r   r!   r   r   statchmodst_modeS_IEXECinfoensure_filer   )r#   sts     r   r:   PostCustomScript.executeM   s     			;T=N=NO		GGLL 4 L L 		
 WWT&&'
""BJJ$=>=>-HHIr   )rB   rA   )r	   r
   r   r   r$   r:   r   __classcell__)rC   s   @r   r=   r=   E   s    
J Jr   r=   )loggingr   rF   	cloudinitr   r   	getLoggerr	   r,   	Exceptionr   r   r   r6   r=   r   r   r   <module>rS      s_     	   !	9 	8 8
 
:Lo LJ Jr   