| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/cloudinit/config/__pycache__/ |
Upload File : |
3
��b � @ sT d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z e Z
dZdZd d
� Z
dS )a
Rightscale Userdata
-------------------
**Summary:** support rightscale configuration hooks
This module adds support for RightScale configuration hooks to cloud-init.
RightScale adds a 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
**Internal name:** ``cc_rightscale_userdata``
**Module frequency:** per instance
**Supported distros:** all
**Config keys**::
CLOUD_INIT_REMOTE_HOOK=<url>
� N)�parse_qs)�
url_helper)�util)�PER_INSTANCEZcc_rightscale_userdataZCLOUD_INIT_REMOTE_HOOKc # C s� y|j � }W n tk
r, |jd| � d S X y,t|�}| sFt|krX|jd| t� d S W n$ tk
r~ tj|d|� � Y nX g }g }|jd�} |t }
x�t|
�D ]�\}}t j
j| d| �}
y6tj
|�}|j� r�|jr�tj|
|dd� |j|
� W q� tk
�r4 } z"|j|� tj|dt||
� W Y d d }~X q�X q�W |�rP|jd t|�� t|�t|
�k�r~t|
�t|� }|jd
|� |�r�|jdt|�� |d
�d S )Nz'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 dictionary�scriptszrightscale-%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� ���)Zget_userdata_raw� Exception�debugr �MY_HOOKNAMEr ZlogexcZ
get_ipath_cur� enumerate�os�path�join�uhelpZreadurl�ok�contentsZ
write_file�append�MY_NAME�lenZwarning)�nameZ_cfgZcloud�logZ_argsZudZmdictZ wrote_fnsZcaptured_excpsZ scripts_dZurls�iZurlZfnameZresp�eZskipped� r �,/usr/lib/python3.6/cc_rightscale_userdata.py�handleA sT
$
r )�__doc__r Zurllib.parser Z cloudinitr r r Zcloudinit.settingsr Z frequencyr r r r r r r �<module>! s