
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!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ƒ }|r¬t|ƒ|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.   
