Your IP : 216.73.217.13


Current Path : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_rightscale_userdata.cpython-38.pyc

U

�Ad7�	@s�UddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZdd
lmZdZdZd
Zdddeegeggd�Zeed<ee�Zeee
eedd�dd�ZdS)�N)�Logger)�parse_qs)�
url_helper)�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�PER_INSTANCEZcc_rightscale_userdataZCLOUD_INIT_REMOTE_HOOKaIThis module adds support for RightScale configuration hooks to cloud-init.
RightScale adds an entry in the format ``CLOUD_INIT_REMOTE_HOOK=http://...`` to
ec2 user-data. This module checks for this line in the raw userdata and
retrieves any scripts linked by the RightScale user data and places them in the
user scripts configuration directory, to be run later by ``cc_scripts_user``.

.. note::
    the ``CLOUD_INIT_REMOTE_HOOK`` config variable is present in the raw ec2
    user data only, not in any cloud-config parts

**Raw user data schema**::

    CLOUD_INIT_REMOTE_HOOK=<url>
zRightScale Userdataz&Support rightscale configuration hooks)�id�name�titleZdescriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keys�meta)r
�cfg�cloud�log�args�returncCs�t|dd�}|rt|�s(|�d|�dS|�}z,t|�}|rDt|krX|�d|t�WdSWn$tk
r~t�|d|��YnXg}g}	|�d�}
|t}t	|�D]�\}}
t
j�|
d|�}z6t
�|
�}|��r�|jr�tj||dd�|�|�Wq�tk
�r2}z |	�|�t�|d	t|
|�W5d}~XYq�Xq�|�rL|�d
t|��t|�t|�k�rzt|�t|�}|�d|�|	�r�|�dt|	��|	d
�dS)N�get_userdata_rawz'Failed to get raw userdata in module %sz:Skipping module %s, did not find %s in parsed raw userdataz1Failed to parse query string %s into a dictionaryZscriptszrightscale-%02ii�)�modez!%s failed to read %s and write %sz)Wrote out rightscale userdata to %s filesz%s urls were skipped or failedz2%s failed with exceptions, re-raising the last one���)�getattr�callable�debugr�MY_HOOKNAME�	ExceptionrZlogexcZ
get_ipath_cur�	enumerate�os�path�join�uhelpZreadurl�ok�contentsZ
write_file�append�MY_NAME�lenZwarning)r
rrrrrZudZmdictZ	wrote_fnsZcaptured_excpsZ	scripts_dZurls�iZurl�fnameZresp�eZskipped�r*�I/usr/lib/python3/dist-packages/cloudinit/config/cc_rightscale_userdata.py�handleIsh�
�


��r,)rZloggingrZurllib.parserZ	cloudinitrr!rZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarr	Zcloudinit.distrosr
Zcloudinit.settingsrr%rZMODULE_DESCRIPTIONr�__annotations__�__doc__�str�listr,r*r*r*r+�<module>	s<��