Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceAkamai.cpython-310.pyc
o

}��f�2�	@s.ddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZmZddlmZmZddlmZdd	lmZmZmZe�e�Zd
dd�d
ddd�ddddddgd�ZGdd�de	�Z Gdd�dej!�Z"Gdd�de"�Z#e#ej$ffe"ej$ej%ffgZ&deej!fdd�Z'dS)�N)�	b64decode)�suppress)�Enum)�Any�List�Tuple�Union)�sources�
url_helper�util)�find_fallback_nic�get_interfaces_by_mac)�EphemeralIPNetwork)�get_dmi_config�get_local_instance_id�is_on_akamaizhttp://169.254.169.254zhttp://[fd00:a9fe:a9fe::1]��ipv4�ipv6z	/v1/tokenz/v1/instancez
/v1/user-data)�token�metadata�userdataTzf2:3)�	base_urls�paths�allow_local_stage�allow_init_stage�
allow_dhcp�
allow_ipv4�
allow_ipv6�preferred_mac_prefixesc@seZdZdZdZdZdZdS)�MetadataAvailabilityResultzj
    Used to indicate how this instance should behave based on the availability
    of metadata to it
    r��N)�__name__�
__module__�__qualname__�__doc__�
NOT_AVAILABLE�	AVAILABLE�DEFER�r*r*�D/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceAkamai.pyr -s
r c@s�eZdZdZdZdd�Zddededefdd	�Zde	fd
d�Z
de	fdd
�Zde	fdd�Zde
eeeefeffdd�Zddedefdd�Zdefdd�Zdefdd�ZdS)�DataSourceAkamai�AkamaiFcCsJt�d�tj�||||�t�|_t�t	�t�
|ddgi�tg�|_dS)NzSetting up Akamai DataSource�
datasourcer-)
�LOG�debugr	�
DataSource�__init__�dictrr�
mergemanydictr�get_cfg_by_path�BUILTIN_DS_CONFIG�ds_cfg)�self�sys_cfg�distrorr*r*r+r2<s
��
�zDataSourceAkamai.__init__�	path_name�use_v6�returncCsZ||jdvrtd�|���d}|s|jdsd}|jd|}|jd|}d�||�S)z�
        Looks up the path for a given name and returns a full url for it.  If
        use_v6 is passed in, the IPv6 base url is used; otherwise the IPv4 url
        is used unless IPv4 is not allowed in ds_cfg
        rzUnknown path name {}rrrrz{}{})r7�
ValueError�format)r8r;r<�version_key�base_url�pathr*r*r+�
_build_urlNszDataSourceAkamai._build_urlcCsN|jds
|jdr|jds|jdst�d�tjS|jr#|��S|��S)z�
        Returns whether metadata should be retrieved at this stage, at the next
        stage, or never, in the form of a MetadataAvailabilityResult.
        rrrrz*Configuration prohibits fetching metadata.)r7r/�infor r'�local_stage�_should_fetch_data_local�_should_fetch_data_network�r8r*r*r+�_should_fetch_data`s����
z#DataSourceAkamai._should_fetch_datacCsD|jds
t�d�tjS|jds|jdst�d�tjStjS)z�
        Returns whether metadata should be retrieved during the local stage, or
        if it should wait for the init stage.
        rz)Configuration prohibits local stage setuprrz9Configuration does not allow for ephemeral network setup.�r7r/rDr r)r(rHr*r*r+rFts

�z)DataSourceAkamai._should_fetch_data_localcCs |jds
t�d�tjStjS)zS
        Returns whether metadata should be fetched during the init stage.
        rz1Configuration does not allow for init stage setuprJrHr*r*r+rG�s

z+DataSourceAkamai._should_fetch_data_networkcs�g}|jrat�}d}|jd}|��D]\�}t�fdd�|D��r&|}nq|dur3t�d�t�}g}|jdrH|�t	|j
|ddd	�df�|jd
r_|jdr_|�t	|j
|dd�df�|S|jdrn|�t�df�|jd
r{|�t�df�|S)
z�
        Returns a list of context managers which should be tried when setting
        up a network context.  If we're running in init mode, this return a
        noop since networking should already be configured.
        Nrcsg|]}��|��qSr*)�
startswith)�.0�prefix��macr*r+�
<listcomp>�szBDataSourceAkamai._get_network_context_managers.<locals>.<listcomp>zGFailed to find default interface, attempting DHCP on fallback interfacerFTrrr)r)rEr
r7�items�anyr/�warningr�appendrr:�noop)r8�network_context_managers�
interfaces�	interface�preferred_prefixes�infr*rNr+�_get_network_context_managers�sl
�
���
������
���
��z.DataSourceAkamai._get_network_context_managersc
Cs:z}tj|jd|d�ddddddid	�}|jd
kr"t�d|j�WdSt|�}tj|jd
|d�dddd|d�d�}t�t|��|_	tj|jd|d�dddd|id�}t|�|_
zt|j
���|_
WWdSt
jy}}zt�d|�WYd}~WdSd}~wwtjy�}zt�d|r�dnd|�WYd}~dSd}~ww)z�
        Runs through the sequence of requests necessary to retrieve our
        metadata and user data, creating a token for use in doing so, capturing
        the results.
        r�r<�PUT�r"�zMetadata-Token-Expiry-Seconds�300)�request_method�timeout�sec_between�retries�headers��z-Fetching token returned %s; not fetching dataTrzapplication/json)�Accept�Metadata-Token)rbrcrdrerrhz*Failed to base64 decode userdata due to %sNz1Failed to retrieve metadata using IPv%s due to %s�6�4F)r
�readurlrC�coder/rD�str�json�loadsr�userdata_rawr�decode�binascii�ErrorrS�UrlError)r8r<�token_responserrr�er*r*r+�_fetch_metadata�sj��

���
��
	���
���z DataSourceAkamai._fetch_metadatac	Cs�t�d�t�st�d�dSt�}d|i|_|��}|tjkr3|tj	kr,t�d�dSt�d�dS|�
�}|D]2\}}|�$|j|d�}|r\|j�d	|�|jd<	Wd
�dSWd
�n1sfwYq9t�
d�dS)zW
        Overrides _get_data in the DataSource class to actually retrieve data
        z#Getting data from Akamai DataSourcez#Not running on Akamai, not running.Fzinstance-idz5Metadata is not available, returning local data only.TzFConfigured not to fetch data at this stage; waiting for a later stage.r\�idNzHFailed to contact metadata service, falling back to local metadata only.)r/r0rrDrrrIr r(r'r[rw�getrS)r8�local_instance_id�availabilityrV�managerr<�doner*r*r+�	_get_data'sJ

�

��
������zDataSourceAkamai._get_datacCst�|��d�S)zj
        A local-only check to see if the instance id matches the id we see on
        the system
        zsystem-serial-number)r	�instance_id_matches_system_uuid�get_instance_id)r8r9r*r*r+�check_instance_id[s�z"DataSourceAkamai.check_instance_idN)F)r#r$r%�dsnamerEr2rm�boolrCr rIrFrGrrrrrr[rwr~r�r*r*r*r+r,8s
�OD4r,c@seZdZdZdZdS)�DataSourceAkamaiLocalz�
    A subclass of DataSourceAkamai that runs the same functions, but during the
    init-local stage.  This allows configuring networking via cloud-init, as
    networking hasn't been configured yet.
    TN)r#r$r%r&rEr*r*r*r+r�esr�r=cCst�|t�S)N)r	�list_from_depends�datasources)�dependsr*r*r+�get_datasource_listsr�)(rrrn�logging�base64r�
contextlibrrU�enumr�typingrrrr�	cloudinitr	r
r�
cloudinit.netrr
�cloudinit.net.ephemeralr� cloudinit.sources.helpers.akamairrr�	getLoggerr#r/r6r r1r,r��DEP_FILESYSTEM�DEP_NETWORKr�r�r*r*r*r+�<module>sP
����/
���

Spamworldpro Mini