HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_rightscale_userdata.cpython-310.pyc
o

�Ad7�@s�UddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZdd
lmZdZdZ	d
Zdddeegeggd�Zeed<ee�Zdedede
dededdfdd�ZdS)�N)�Logger)�parse_qs)�
url_helper)�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�PER_INSTANCE�cc_rightscale_userdata�CLOUD_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�title�description�distros�	frequency�examples�activate_by_schema_keys�metar�cfg�cloud�log�args�returncCs�t|dd�}|rt|�s|�d|�dS|�}zt|�}|r"t|vr,|�d|t�WdSWnty<t�|d|��wg}g}	|�d�}
|t}t	|�D]H\}}
t
j�|
d|�}zt
�|
�}|��ru|jrutj||dd�|�|�WqNty�}z|	�|�t�|d	t|
|�WYd}~qNd}~ww|r�|�d
t|��t|�t|�kr�t|�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 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���)�getattr�callable�debugr�MY_HOOKNAME�	Exceptionr�logexc�
get_ipath_cur�	enumerate�os�path�join�uhelp�readurl�ok�contents�
write_file�append�MY_NAME�len�warning)rrrrrr�ud�mdict�	wrote_fns�captured_excps�	scripts_d�urls�i�url�fname�resp�e�skipped�r@�I/usr/lib/python3/dist-packages/cloudinit/config/cc_rightscale_userdata.py�handleIsh����


�

�����rB)r(�loggingr�urllib.parser�	cloudinitrr+r�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemarr	�cloudinit.distrosr
�cloudinit.settingsrr1r#�MODULE_DESCRIPTIONr�__annotations__�__doc__�str�listrBr@r@r@rA�<module>sJ
�������