
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
\mei              	   @   s   U d Z ddl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eZ eee
eddddZdS )z:Bootcmd: run arbitrary commands early in the boot process.    N)dedent)subp
temp_utilsutil)Cloud)Config)
MetaSchemaget_meta_doc)
PER_ALWAYSallZ
cc_bootcmdZ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distrosZexamples	frequencyZactivate_by_schema_keys)r   cfgcloudargsreturnc       
       C   s   d|krt jd|  d S tjdd}y*tj|d }|jtj| |j  W n6 t	k
r } ztj
t dt|  W Y d d }~X nX y@tjj }|j }|rt||d< d|jg}	tj|	|dd	 W n$ t	k
r   tj
t d
|   Y nX W d Q R X d S )Nr   z;Skipping module named %s, no 'bootcmd' key in configurationz.sh)suffixzFailed to shellify bootcmd: %sZINSTANCE_IDz/bin/shF)envZcapturezFailed to run bootcmd module %s)LOGdebugr   ZExtendedTemporaryFiler   ZshellifywriteZencode_textflush	ExceptionZlogexcstrosenvironcopyZget_instance_idr   r   )
r   r   r   r   ZtmpfZcontenter   Ziidcmd r$    /usr/lib/python3.6/cc_bootcmd.pyhandleD   s,    

r&   )__doc__Zloggingr   textwrapr   Z	cloudinitr   r   r   Zcloudinit.cloudr   Zcloudinit.configr   Zcloudinit.config.schemar   r	   Zcloudinit.settingsr
   Z	getLogger__name__r   r   r   metar   listr&   r$   r$   r$   r%   <module>
   s.   
