
    f%              
           U d Z ddlZddlm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mZ ddlmZ  ej"                  e      ZeZd	gZd
dd ed      e ed      gedgdZeed<    ee      Z dedede	deddf
dZy)z:Bootcmd: run arbitrary commands early in the boot process.    N)dedent)subp
temp_utilsutil)Cloud)Config)
MetaSchemaget_meta_doc)
PER_ALWAYSall
cc_bootcmdBootcmdz0Run arbitrary commands early in the boot processa          This module runs arbitrary commands very early in the boot process,
        only slightly after a boothook would run. This is very similar to a
        boothook, but more user friendly. The environment variable
        ``INSTANCE_ID`` will be set to the current instance id for all run
        commands. Commands can be specified either as lists or strings. For
        invocation details, see ``runcmd``.

        .. note::
            bootcmd should only be used for things that could not be done later
            in the boot process.

        .. note::

          when writing files, do not use /tmp dir as it races with
          systemd-tmpfiles-clean LP: #1707222. Use /run/somedir instead.
    z        bootcmd:
            - echo 192.168.1.130 us.archive.ubuntu.com > /etc/hosts
            - [ cloud-init-per, once, mymkfs, mkfs, /dev/vdb ]
    bootcmd)idnametitledescriptiondistrosexamples	frequencyactivate_by_schema_keysmetar   cfgcloudargsreturnc           	      v   d|vrt         j                  d|        y t        j                  d      5 }	 t	        j
                  |d         }|j                  t	        j                  |             |j                          	 |j                         }|rdt        |      ini }t        j                  d|j                  g|d	       	 d d d        y # t        $ r*}t	        j                  t         dt        |              d }~ww xY w# t        $ r t	        j                  t         d
|         w xY w# 1 sw Y   y xY w)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envs	            =/usr/lib/python3/dist-packages/cloudinit/config/cc_bootcmd.pyhandler3   C   s   		I4	
 			)	)	7 4	mmC	N3GJJt''01JJL
	'')C/2=#c(+CIIy$)),eL 
  	KK=s1vF	  	KK>E	 s<   D/ACAD	D%C>>DD/&D,,D//D8)__doc__loggingtextwrapr   	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar	   r
   cloudinit.settingsr   	getLogger__name__r"   r   r   r   __annotations__r+   listr3        r2   <module>rB      s    A   , , ! # < )g!	' ?	& 	
  ){E#j #J t
 6 % t  rA   