o
    f                  
   @   s   U d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ eeZeZdd	ged
gdZeed< dede	dededdf
ddZdS )z:Bootcmd: run arbitrary commands early in the boot process.    N)subp
temp_utilsutil)Cloud)Config)
MetaSchema)
PER_ALWAYS
cc_bootcmdallbootcmd)iddistros	frequencyactivate_by_schema_keysmetanamecfgcloudargsreturnc           	      C   s   d|vrt d|  d S tjdd`}zt|d }|t| |  W n t	y> } z
t
t dt|  d }~ww z| }|rLdt|ini }tjd|jg|dd	 W n t	yi   t
t d
|   w W d    d S 1 suw   Y  d S )Nr   z;Skipping module named %s, no 'bootcmd' key in configurationz.sh)suffixzFailed to shellify bootcmd: %sINSTANCE_IDz/bin/shF)
update_envcapturezFailed to run bootcmd module %s)LOGdebugr   ExtendedTemporaryFiler   shellifywriteencode_textflush	Exceptionlogexcstrget_instance_idr   r   )	r   r   r   r   tmpfcontenteiidenv r*   =/usr/lib/python3/dist-packages/cloudinit/config/cc_bootcmd.pyhandle!   s2   "r,   )__doc__logging	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.settingsr   	getLogger__name__r   r   r   __annotations__r#   listr,   r*   r*   r*   r+   <module>   s   	
"